class Item(models.Model):
name = models.CharField(max_length=50)
item_price = models.DecimalField(max_digits=5, decimal_places=2)
class Magazine(models.Model):
name = models.CharField(max_length=50)
items = models.ManyToManyField('Item', blank=True, null=True)
owner = models.ForeignKey(User, related_name='u_item')
雑誌のすべてのアイテムの価格の合計を取得するにはどうすればよいですか?
ビューで:
...
user = request.user
magazins = Magazine.objects.filter(owner= user)
...