【发布时间】:2020-06-25 13:15:09
【问题描述】:
我有这个模型
class Invoice(models.Model):
field1= models.DecimalField(blank=True,null=True,decimal_places=2,max_digits=10)
amount_field2= models.DecimalField(blank=True,null=True,decimal_places=2,max_digits=10)
price_field2= models.DecimalField(blank=True,null=True,decimal_places=2,max_digits=10)
我可以有几张发票,所以我想对所有发票进行类似 (amount_field2*price_field2) 和 SUM 的操作,以便最终获得总计。在我看来,我需要这样做,因为我不想将总数返回到我的模板。
【问题讨论】:
标签: django django-views django-queryset