如何自定义 django admin 的可点击 list_editable
目前,我有一个类 MyAdmin(admin.ModelAdmin),其中有一个名为 name 的字段,它属于 list_editable 和 list_display 。当前的行为是 list_editable 中的所有字段都显示表单字段。但是,我想更改只有当人们单击该字段时它才会变成可编辑的表单字段。
谁能指出我如何做到这一点的正确方向(要编辑哪个模板等)。
非常感谢!
贾森
Currently, i have a class MyAdmin(admin.ModelAdmin), and i have a field in there called name, which belongs to both list_editable and list_display. The current behavior is such that all fields that is in list_editable displays a form field. However, i would like to change that only when people click on the field would it turn into a editable form field.
Can anyone point me in the right direction on how to do that (which template to edit etc.).
Thank you very much!
Jason
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 model.ModelAdmin 中的 list_editable。我解决点击编辑的方法是使用一些 JavaScript 魔法,仅当用户单击该字段时才显示编辑字段。
Look at list_editable in model.ModelAdmin. The way I solved click to edit is to use some javascript wizardry to display the edit field only if the user clicks on the field.
也许类似的东西 http://www.appelsiini.net/projects/jeditable 指出你正确的方向?
Maybe something like that http://www.appelsiini.net/projects/jeditable points you in the right direction?