django忽略查询中模型定义的排序参数

时间:2010-08-20 09:55:13

标签: django

在我的模特上我有

class Meta:
    ordering = ['title']

有没有一种方法可以将其留在模型定义中,因为它在其他地方有用但在查询中告诉它在没有顺序的情况下忽略它?

1 个答案:

答案 0 :(得分:3)

文档是您的朋友:http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields

New in Django 1.0: Please, see the release notes

If you don't want any ordering to be applied to a query, 
not even the default ordering,  call order_by() with no parameters.