django - ordering queryset by a calculated field

后端 未结 6 710
故里飘歌
故里飘歌 2020-11-30 04:22

I want to have a model with calculated fields that I can apply sorting on. For example, let\'s say that I have the following model:

class Foo(models.Model):
         


        
6条回答
  •  时光说笑
    2020-11-30 04:50

    I would take a look at the extra method on Queryset and specify the order_by parameter.

提交回复
热议问题