Database Reference
In-Depth Information
from django.conf.urls import patterns,
include, url
from django.conf import settings
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/',
include(admin.site.urls)),
)
# media files
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$',
'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT})
)
13. In the urls.py file, you basically defined the location of the back office
(which was built using the Django admin application), and the media (im-
ages)files'locationuploadedbytheDjangoadministratorwhenaddingnew
animal entities in the database. Now, run the Django development server
using the following runserver management command:
(chp09-env)$ python manage.py runserver
14. AccesstheDjangoadminsiteat http://localhost:8000/admin/ ,and
log in with the superuser credentials you furnished in an earlier step in this
recipe when you initially synced the Django database.
15. Now, navigate to http://localhost:8000/admin/sightings/anim-
al/ andaddsomeanimalsusingthe Add animal button.Foreachanimal,
define a name and an image that will be used by the frontend that you will
build in the next recipe. You created this page with almost no code, thanks
totheDjangoadmin!Thefollowingscreenshotshowswhatthe Animals list
page will look like after adding some entities:
Search WWH ::




Custom Search