Receive our weekly advanced programming tips for FREE
23.May
How to active the admin in django
0
| 0 votes
Autor: bookkeeper
Chapter: Django
The nicest feature about django is the build-in admin. To activate you need to do:


1. Change into a app folder for example "data"

2. Create a file "admin.py" and edit it


from django.contrib import admin
from blog.apps.data.models import Entry
admin.site.register( Entry )

We tell django with (admin.site.register) which our models should appear in our admin

3. Edit the global urls.py and uncomment the admin parts

from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
    (r'^', include('blog.apps.homepage.urls')),
    # Example:
    # (r'^blog/', include('blog.foo.urls')),
    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
)


4. Edit the global settings.py

5. Uncomment the "django.contrib.admin" in INSTALLED_APPS

INSTALLED_APPS = (
    ...
    'apps.data',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    ...
)


6. Run python manage.py syncdb, it will install the new admin tables

7. Start the dev server, python manage.py runserver

8. Point your browser to http://127.0.0.1/admin/ and login.


The admin is ready to use :)