gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 00:38:41 25 4
gpt4 key购买 nike

在我的模型上有

class Meta:
ordering = ['title']

有没有一种方法可以将它保留在模型定义中,因为它在其他地方很有用,但在查询中告诉它忽略它而不用排序?

最佳答案

文档是您的 friend :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.

关于django 忽略查询中模型定义的排序参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3529811/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com