Adding a movie model to admin
To add the movie model to admin, go back to /movie/admin.py
, and register our model with the following:
from django.contrib import admin
from .models import Movie
admin.site.register(Movie)
When you save your file, go back to admin. The movie model will now show up (as shown in Figure 5.8):
Try adding a movie
object by clicking on +Add. You will be brought to the Add movie form (as shown in Figure 5.9):
Note that Url is not in bold, as we marked it as optional back in models.py
, url = models.URLField(blank=True)
. The other required fields are in bold.
Try adding a movie and hit Save. Your movie object will be saved to the database and reflected in the admin page (as shown in Figure 5.10):
You can also see the movie image in /moviereviews/media/movie/images/<...