As I mentioned in the previews post (Part 3), that django have a admin page, and will generate the admin form from the models. Django admin can be access from url using /admin. If you can't access admin page, please make sure you have activate the admin. To activate the admin page, look at setting.py and url.py.

Make sure, django.contrib.admin added on INSTALLED_APPS in setting.py :

1
2
3
4
5
INSTALLED_APPS = (
    ...
    'django.contrib.admin',
    ...
)

 

Also make sure, that the following code are exist in url.py :

1
2
3
4
5
6
7
8
...
from django.contrib import admin
admin.autodiscover()
...
 
urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
)

 

When it is done, run the server and access the admin from the url http://localhost:8000/admin/

django admin panel 

Look at the picture, the admin page is active, but our app (article) didn't listed.

Now, we setting the admin to list the article app 

Register App 

Please open the admin.py file inside of article app directory 

The default code is :

1
2
3
from django.contrib import admin
 
# Register your models here.

and now, make the code like this: 

1
2
3
4
5
6
7
from django.contrib import admin
from article.models import Category, Post
 
# Register your models here.
 
admin.site.register(Category)
admin.site.register(Post)

and now, see the admin page, buumb the article menu shown with submenu category and post Cool 

django admin with article app registered 

So you can add the category and post now Wink

Next?

Next, we will prepare the front end, using bootstrap template 

Thanks   

Comments

Add comment

authimage