动态自定义 django 管理列?
是否可以让用户动态选择/更改 Django 管理中对象列表中显示的列?
通过修改“change_list.html”模板,事情肯定可以“从头开始”实现,但我想知道是否有人已经遇到了同样的问题和/或是否有任何 django-pluggin 可以做到这一点。
提前致谢,
Is it possible to let the users choose / change dynamically the columns displayed in a object list in Django administration ?
Things can surely be implemented "from scratch" by modifying the 'change_list.html' template but I was wondering if somebody has already had the same problem and/or if any django-pluggin can do that.
Thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从 Django 1.4 开始,您可以使用 get_list_display() 来执行此操作: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_list_display
Since Django 1.4 you can do this using get_list_display(): https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_list_display
django-xadmin 具有以下功能:
它还有一些其他很酷的功能,但我还没有开始使用它,因为文档的英文翻译尚未发布(截至 10 月) '13)。您可以查看源代码来给您一些想法。
查看现场演示
用户:admin
密码:admin
注意:我没有参与x-admin,我只是有与OP相同的问题。
django-xadmin has this feature:
It has some other cool features too, but I haven't started using it because the English translation of the documentation hasn't been released yet (as of Oct '13). You could look at the source code to give you some ideas.
Check out the live demo
User: admin
Password: admin
Note: I have no involvement in x-admin, I just have the same question as the OP.
如果我正确解释了您的问题,解决方案是在该对象的 ModelAdmin 扩展中设置 list_display 。请参阅 Django 教程,第 2 部分< /a>.
If I've interpreted your question correctly, the solution is to set list_display in your extension of ModelAdmin for that object. Refer to the Django Tutorial, Part 2.