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)
答案 0 :(得分:1)
我认为你需要
from django.db.models import Sum
Product.objects.filter(id=product_id).aggregate(Sum('attribute__price_update'))