我知道如何在 Django 管理中更改或扩展模型的视图 ( http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.add_view )但我想扩展管理索引(仪表板)视图。
具体来说,我想保持不变,但向我的一些模型添加一些信息,以便我将它们分类到“A”列或“B”列,具体取决于模型是模型“A”还是模型“的子类” B'。
我已经能够毫无问题地更改索引模板,但是将模型按照描述的方式排序为两列似乎是我需要在视图中执行的操作。我也不想重写整个视图,只需扩展它。
谢谢!
I know how to change or extend a model's views in the Django admin ( http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.add_view ) but I want to extend the admin index (dashboard) view.
Specifically, I want to keep it the same, but add some information to some of my models that will let me sort them into column 'A' or column 'B' depending on if the models are subclasses of model 'A' or model 'B'.
I've been able to change the index template no problem, but getting the models to sort into two columns as described seems like something I need to do in the view. I also don't want to have to rewrite the entire view, only extend it.
Thanks!
发布评论
评论(1)
为什么要更改模板?您可以使用 ModelAdmin.list_display< /a> 用于打印这些列。
编辑: 对于订购,您可以使用 ModelAdmin.ordering。
Why do you want to change the templates? You can use ModelAdmin.list_display for printig these columns.
Edit: And for ordering you can use ModelAdmin.ordering.