1👍
✅
If you have a through=…
model [Django-doc], then that model needs two ForeignKey
s: one to the "source" model, and one to the Target
model, since a ManyToManyField
is always a model (sometimes an implicit) one that has two ForeignKey
s to link two other models together: it is implemented as a junction table [wiki].
class Season(models.Model):
season = models.CharField(max_length=10)
buyer = models.ForeignKey(Buyer, on_delete=models.CASCADE)
fruit = models.ForeignKey(Fruit, on_delete=models.CASCADE)
Source:stackexchange.com