Django admin

Django comes with an automatic admin interface.

We just created a (database) model in the previous article. Now we can create a backend management tool for it.

This is one of the most powerful features of Django.

You may like: Python and Django Full Stack Web Developer Bootcamp

Admin interface

You can open the admin interface with a web browser, but to open the admin interface, first we need to change a file. Open the file movies/admin.py
This is the file contents:

Lets add some code:

Start the Django server:

python manage.py runserver

Open the url: http://127.0.0.1:8000/admin/

Admin login

Note: that’s http://127.0.0.1:8000/admin/

 
A login screen will popup. Let’s enter the matrix!

django admin

Django admin add user

Create a superuser.

python manage.py createsuperuser

Type a username and password. You should see this message:

Superuser created successfully.

Now open the webpage again and login.

The admin screen

If you see the screen below, good job!

django site admin

The model ‘Movie’ is there!

Django admin add

If you click on the model, a new screen shows up:

django add to model

We can add new movies here. If you click on the button, all the fields are there to add a new movie, exactly as we specified it in the model.

django insert into database

How cool is that?
All the CRUD operations work.

Note: CRUD is short for create, read, update and delete. Common database operations

 
We can now interact with the complete database system from this graphical interface.

Previous Post

Leave a Reply