Reputation: 1581
class attributes(models.Model):
attribute_name = models.CharField(max_length = 200, db_index = True)
price_update = models.DecimalField(max_digits = 10,
decimal_places = 2)
class Product(models.Model):
attribute = models.ManyToManyField(attributes)
Upvotes: 0
Views: 234
Reputation: 20369
I think you need
from django.db.models import Sum
Product.objects.filter(id=product_id).aggregate(Sum('attribute__price_update'))
Upvotes: 1