Complete the code to define a ForeignKey field in a Django model.
class Comment(models.Model): post = models.[1]('Post', on_delete=models.CASCADE) content = models.TextField()
The ForeignKey field creates a one-to-many relationship in Django models.
Complete the code to specify the behavior when the related object is deleted.
post = models.ForeignKey('Post', on_delete=models.[1])
CASCADE deletes related comments when the post is deleted.
Fix the error in the ForeignKey declaration to allow null values.
post = models.ForeignKey('Post', on_delete=models.CASCADE, [1]=True)
Setting null=True allows the ForeignKey field to be empty in the database.
Fill both blanks to define a ForeignKey with a related name and allow null values.
post = models.ForeignKey('Post', on_delete=models.CASCADE, [1]=True, related_name='[2]')
null=True allows nulls; related_name='comments' lets you access comments from a post.
Fill all three blanks to create a ForeignKey with CASCADE delete, allow blank input, and set a related name.
post = models.ForeignKey('Post', on_delete=models.[1], blank=[2], related_name='[3]')
on_delete=models.CASCADE deletes related objects; blank=True allows empty input in forms; related_name='comments' names the reverse relation.