Adding a movie model to the admin panel
We are now ready to create movies from the admin panel and store the images in our Django project. We will add the Movie
model to the admin panel, and we will create movies.
Adding the Movie model to the admin panel
To add the Movie
model to the admin panel, go back to /movies/admin.py
and register our model by adding the following in bold:
from django.contrib import admin from .models import Movie admin.site.register(Movie)
When you save your file, stop the server, run the server, and go back to /admin
. The Movie
model will now appear (as shown in Figure 5.8):
Figure 5.8 – Admin page with movies available
Try adding a movie
object by clicking +Add. You will be brought to the Add movie form, as shown in Figure 5.9:
Figure 5.9 – The Add movie form
Try adding a movie and hit Save. Your movie object will be saved to the database and reflected in the admin page,...