Complete the code to define a many-to-many relationship using a through model.
class Book(models.Model): authors = models.ManyToManyField(Author, through=[1])
The through parameter should be the name of the intermediate model that holds extra fields.
Complete the through model with the correct field type for the foreign key to Book.
class BookAuthor(models.Model): book = models.[1](Book, on_delete=models.CASCADE)
The through model uses ForeignKey fields to link to each related model.
Fix the error in the through model by completing the field for author.
class BookAuthor(models.Model): author = models.[1](Author, on_delete=models.CASCADE)
The author field must be a ForeignKey to the Author model to link properly.
Fill both blanks to add an extra field and a string representation method in the through model.
class BookAuthor(models.Model): book = models.ForeignKey(Book, on_delete=models.CASCADE) author = models.ForeignKey(Author, on_delete=models.CASCADE) [1] = models.IntegerField(default=0) def __str__(self): return f"[2] by [3] with contribution [1]%"
The extra field is named contribution to store extra info. The string method uses self.book and self.author to show related objects.
Fill all three blanks to create a query that filters BookAuthor entries with contribution greater than 50.
high_contrib = BookAuthor.objects.filter([1]__[2]=[3])
To filter by contribution greater than 50, use contribution__gt=50 in the filter.