Creating Django Personal App – Part 5 – Django admin

At this point we have a functional website but we are going to unleash the true power of Django, the admin interface. Go to http://localhost:8000/admin and you will get something like shown below:

Django admin

There is a problem, we don’t have a username and a password. No problem, we are going to create one. It is called the superuser and to create one just run the following command in the terminal:

python createsuperuser

This is what I got as output:

(MyWebsite) ddn_ro@Linux:~/PythonProjects/MyWebsite/mywebsite$ python createsuperuser
Username (leave blank to use 'XXXXX): 
Email address:
Password (again): 
Superuser created successfully.
(MyWebsite) ddn_ro@Linux:~/PythonProjects/MyWebsite/mywebsite$ 

Once you are done, go back to the login page and login with the username and password.

Django admin signed in

Now, we have groups and users, and we can play with that but, we want to add blog posts through the Django administration interface. For that, we have to edit the blog/ file.

This is how the edited blog/ file should be:

from django.contrib import admin
from blog.models import Post

# Register your models here.

All I did is to register the Post model with the

Now, if you refresh the Django administration page you will see the Blog section.

Django admin register Post

Now you can add a post. I am going to add five dummy posts for testing purposes. At the Blog section go to Posts and on the right hand side click the Add button. You will be taken to a page where you can add blog posts.

Django admin add posts

Once you finish creating the blog posts, go to the home page of your site (http://localhost:8000) then visit the blog page (http://localhost:8000/blog/). You should see all the blog posts listed there.

Django blog page

There you have it! A page full of blog posts! In part 6 we will take care of the individual blog posts.

Leave a Reply