开发者

Django Admin: How do I set the ordering of inline elements?

With开发者_Go百科 a normal ModelAdmin class I can set the ordering with:

ordering = ("field_name",)

There seems to be no option to set ordering for InlineModelAdmin. Is there a way to get the inline elements to sort by a particular field?


This works now so you can just do something like:

class MyModelInline(admin.TabularInline):
   model = MyModel
   ordering = ("field_name",)


There's actually a ticket for this, with a patch here: http://code.djangoproject.com/ticket/13862

Don't know if it actually works, though.


Update: The ticket is marked as fixed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜