django 聚合函数

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的销售总数


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章