django 聚合函数

来源:互联网 发布:windows 远程桌面连接 编辑:程序博客网 时间:2024/05/16 02:00

Talk is cheap,show you the code!

聚合函数 Sum的用法:

total_sale_num = Saleinfo.filter(product_id="9321374", sku_id=1).aggregate(total_sale_num=Sum('sale_num')).get('total_sale_num') or 0

求出销售信息中的商品id为9321374,规格id为1的销售总数


0 0
原创粉丝点击