有什么方法可以在 django 管理站点中添加选项卡式表单吗?
当使用 Django“开箱即用”管理表单时,对于复杂模型(具有很多字段),“更改表单”页面可能会相当长。
我想在“更改表单”中使用选项卡,这样事情就更具可读性(按选项卡对字段进行分组...)
而不是通过修改“change_form.html”管理模板来自己完成这一切,我想知道是否有人已经这样做并愿意分享代码,或者现有的 Django 插件是否已经存在。
预先感谢您的回答
When using Django "out-of-the-box" administration forms, the "change form" pages can be rather long for complex models (with a lot of fields).
I would like to use tabs in the "change form", so things can be more readable (group fields by tabs...)
Instead of doing it all by myself, by modifiying the 'change_form.html' admin template, I was wondering whether somebody has already done that and would like to share the code, or whether an existing Django-plugin already exist.
Thanks in advance for you answer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定这是否很容易开箱即用,但为什么不将字段放入字段集中并使这些字段集可折叠?它可能稍微不太理想,但开箱即用。 教程中有一个示例:
在此示例中, “日期信息”字段集可以折叠到仅标题栏。
I'm not sure if this is easy to do out of the box, but why not put the fields in fieldsets and make these fieldsets collapsible? It's slightly less ideal possibly, but works out of the box. There's an example in the tutorial:
In this example, the 'Date Information' fieldset can be collapsed to just the title bar.
我编写了一个小应用程序,可以非常轻松地做到这一点: https://github.com/omji/django- tabbed-admin
它尝试以与字段集相同的方式工作以保持 django 逻辑。您只需从选项卡式模型继承您的管理类。您还可以将其与内联混合并按照您想要的方式排序。例如:
I have written a small app do that very easily: https://github.com/omji/django-tabbed-admin
It attemps to work the same way as for the fieldsets to keep the django logic. You just inherit your admin class from the tabbed model. You can also mix it with inlines and order them the way you want. For exemple:
我知道执行此操作的三个选项:
I know three options to do this :