Letting users post movie reviews
We will now implement letting logged-in users post reviews for movies. We have to first create a Review model:
- In
movie/models.py
, add the following to define a Review model:from django.db import models from django.contrib.auth.models import User … class Review(models.Model): text = models.CharField(max_length=100) date = models.DateTimeField(auto_now_add=True) user = models.ForeignKey(User,on_delete=models.CASCADE) movie = models.ForeignKey( Movie,on_delete=models.CASCADE) watchAgain = models.BooleanField() def __str__(self): return self.text
The text
field stores the review text:
text = models.CharField(max_length...