Creating a review model
To store the movies’ review information, we need to create a review Django model and follow the next steps:
- Create the review model.
- Apply migrations.
- Add the review model to the admin panel.
Create the review model
The review information is closely connected to movies. Therefore, we will include this model in the movies
app. In the /movies/models.py
file, add the following parts that are highlighted in bold:
from django.db import models from django.contrib.auth.models import User class Movie(models.Model): … class Review(models.Model): id = models.AutoField(primary_key=True) comment = models.CharField(max_length=255) date = models.DateTimeField(auto_now_add=True) movie = models.ForeignKey(Movie, on_delete=models.CASCADE) user...