2👍
✅
You can use the through
model that you get while using ManyToMany
fields
class Order(models.Model):
items_in_order=models.ManyToManyField('Item', through='Quantity')
class Item(models.Mode):
name=models.Charfield()
price=models.DecimalField()
class Quantity(models.Model):
quantity = models.IntegerField()
order = models.ForeignKey('Order')
item = models.ForeignKey('Item')
Documentation on extra fields on ManyToMany
Source:stackexchange.com