Django管理排序顺序 [英] Django admin sort order

查看:223
本文介绍了Django管理排序顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览了 http://docs.djangoproject.com 上的投票教程。

i have went through the Poll tutorial on http://docs.djangoproject.com.

我想知道在编辑民意调查时是否可以向选择模型添加排序顺序,我将如何实现

I would like to know if it is possible to add a sort order to the 'Choice' Model when editing a Poll and how would i accomplish that

谢谢

推荐答案

class SeminarInline(admin.StackedInline):
    model = Seminar
    extra = 0
    ordering = ('-date',)

为我工作(上面改编自我的模型)
按降序排序

worked for me (above adapted from my model) It sorted in descending date order

这篇关于Django管理排序顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆