Django Python noob - how do I get the NUMBER out of a Aggregate sum?
I have a simple Aggregate:
tot=PurchaseOrderLine.objects.aggregate(total=Sum('price'))
return HttpResponse(tot)
This returns "total".
If I do:
return HttpResponse(str(tot))
It displays "{'total': Decimal('321.60')开发者_开发知识库}"
How do I get the NUMERIC var out of this!
tot=PurchaseOrderLine.objects.aggregate(total=Sum('price'))['total']
return HttpResponse(tot)
精彩评论