【发布时间】:2021-12-08 03:58:36
【问题描述】:
我想按总价值对我的查询进行排序,总价值是项目的外键 我使用下面的方法来计算总量。
models.py 函数
def total(self):
total=0
for item in self.items.all():
if item.taxed==True:
total = total + item.amount + (item.amount*(self.tax)/(100))
else:
total = total + item.amount
return total
我的查询看起来像:
nvoices = Invoices.objects.all().order_by()
【问题讨论】:
标签: python django django-orm