I have a model
class ItemPrice( models.Model ): price = models.DecimalField ( max_digits = 8, decimal_places=2 ) ....
I tried thi
Annotate adds a field to results:
>> Order.objects.annotate(total_price=Sum('price')) , ]> >> orders.first().total_price Decimal('340.00')
Aggregate returns a dict with asked result:
>> Order.objects.aggregate(total_price=Sum('price')) {'total_price': Decimal('1260.00')}