Python Django Tutorial 5 – The built in Admin interface

1. Installing the Admin
Open the settings file and make sure that the following item is added to the INSTALLED_APPS set.

INSTALLED_APPS = (
    'django.contrib.admin',
)

2. Enable Admin URL’s in the project’s urls.py file
After importing the admin module, enable/add the following pattern in the list of urlpatterns:

from django.contrib import admin
urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
]

3. Register the App’s models that need to be shown in Admin
Open the admin.py file created under the articles directory and register the models in this file.

from django.contrib import admin
from article.models import Article

# Register your models here.
admin.site.register(Article)

Now you should be able to add/edit/delete your articles from the admin panel. How cool is that!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s