With a normal ModelAdmin class I can set the ordering with:
使用普通的ModelAdmin类,我可以使用以下命令设置顺序:
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?
似乎没有为InlineModelAdmin设置排序的选项。有没有办法让内联元素按特定字段排序?
2 个解决方案
#1
29
This works now so you can just do something like:
现在可以使用,所以您可以执行以下操作:
class MyModelInline(admin.TabularInline):
model = MyModel
ordering = ("field_name",)
#2
2
There's actually a ticket for this, with a patch here: http://code.djangoproject.com/ticket/13862
实际上有一张这样的票,有一个补丁:http://code.djangoproject.com/ticket/13862
Don't know if it actually works, though.
不过,不知道它是否真的有用。
Update: The ticket is marked as fixed.
更新:故障单标记为已修复。
#1
29
This works now so you can just do something like:
现在可以使用,所以您可以执行以下操作:
class MyModelInline(admin.TabularInline):
model = MyModel
ordering = ("field_name",)
#2
2
There's actually a ticket for this, with a patch here: http://code.djangoproject.com/ticket/13862
实际上有一张这样的票,有一个补丁:http://code.djangoproject.com/ticket/13862
Don't know if it actually works, though.
不过,不知道它是否真的有用。
Update: The ticket is marked as fixed.
更新:故障单标记为已修复。