Django - Can you use property as the field in an aggregation function?

前端 未结 2 1918
孤城傲影
孤城傲影 2020-12-16 11:33

I know the short answer because I tried it. Is there any way to accomplish this though (even if only on account of a hack)?

class Ticket(models.Model):
    a         


        
2条回答
  •  心在旅途
    2020-12-16 11:44

    I have a similar scenario and want exactly the same feature. I solved it trivially with the following line:

    ...
    return sum(lt.cost for lt in self.lineitem_set)
    

提交回复
热议问题