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:
0 1 2 3 4 |
from django.contrib import admin # Register your models here. |
Lets add some code:
0 1 2 3 4 5 |
from django.contrib import admin from .models import Movie admin.site.register(Movie) |
Start the Django server:
Open the url: http://127.0.0.1:8000/admin/
Admin login
A login screen will popup. Let’s enter the matrix!
Django admin add user
Create a superuser.
Type a username and password. You should see this message:
Now open the webpage again and login.
The admin screen
If you see the screen below, good job!
The model ‘Movie’ is there!
Django admin add
If you click on the model, a new screen shows up:
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.
How cool is that?
All the CRUD operations work.
We can now interact with the complete database system from this graphical interface.