开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜