Recall & Review
beginner
What is a through model in Django's many-to-many relationships?
A through model is a custom intermediate model that Django uses to store extra fields on a many-to-many relationship between two models.
Click to reveal answer
beginner
How do you specify a through model in a Django ManyToManyField?
You specify the through model by passing the model class name to the 'through' argument in the ManyToManyField, like: ManyToManyField('OtherModel', through='ThroughModel').Click to reveal answer
intermediate
Why would you use a through model instead of a simple ManyToManyField?
You use a through model when you want to add extra information (fields) to the relationship itself, like a date or status, which a simple ManyToManyField cannot store.
Click to reveal answer
intermediate
In a through model, what fields must you include to link the two related models?
You must include two ForeignKey fields, each pointing to one of the related models, to connect them through the intermediate model.
Click to reveal answer
advanced
How do you add or access extra fields on a many-to-many relationship using a through model?
You create or query instances of the through model directly to set or get extra fields, instead of using the simple add() or remove() methods on the ManyToManyField.
Click to reveal answer
What argument do you use in ManyToManyField to specify a custom through model?
✗ Incorrect
The 'through' argument tells Django which intermediate model to use for the many-to-many relationship.
Which of these is NOT true about a through model?
✗ Incorrect
A through model does not replace the related models; it only acts as an intermediate table with extra fields.
How do you add a relationship with extra fields using a through model?
✗ Incorrect
You create an instance of the through model to set extra fields when adding a relationship.
If you don't specify a through model, what does Django do?
✗ Incorrect
Django automatically creates a simple intermediate table for many-to-many relationships without extra fields.
Which field type is used in a through model to link to the related models?
✗ Incorrect
ForeignKey fields link the through model to each related model in the many-to-many relationship.
Explain how to create a through model in Django to add extra fields on a many-to-many relationship.
Think about how to connect two models with extra info stored in between.
You got /3 concepts.
Describe how you would add a new relationship with extra data using a through model in Django.
Remember, you don't use add() on the ManyToManyField when extra fields exist.
You got /4 concepts.