且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Django中按字段排序

更新时间:2023-01-30 12:19:26

我建议在传递查询集之前在查询集上使用 order_by .文档位于此处.您可以在视图中执行类似 some_query_set.order_by("index")的操作.

I recommend using order_by on your queryset before passing it down. Documentation is here. You can do something like some_query_set.order_by("index")in your views.