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的銷售總數
聚合函數 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的銷售總數