修改django-cms‘添加插件’基于每个插件的模板?
我特别讨论的模板是用户向页面添加插件时使用的模板。无论是在管理区域,还是直接修改页面时,都使用 iframe 显示。
模板本身位于 cms/templates/admin/cms/page/plugin_change_form.html。
我的问题是我需要一些 JavaScript 来填充表单中的下拉列表。所有的 javascript 都是在 iframe 添加到页面之前运行的,所以我想如果我设法编辑模板,我可以告诉 iframe 加载一些特定的 js。显然我可以直接更改模板,但这是一个不太理想的解决方案。我宁愿将其保留在 django 应用程序中,甚至更好地让 js 仅在特定插件上运行。
任何想法表示赞赏。
The template I'm specifically talking about is the one that is used when a user add's a plugin to a page. Both in the admin area, and when modifying pages directly, it is displayed using an iframe.
The template itself is located cms/templates/admin/cms/page/plugin_change_form.html.
My problem is that I need some javascript to populate a drop down list within the form. All the javascript is run before the iframe is added to the page though, so I thought if I managed to edit the template I can tell the iframe to load some specific js. I can obviously just change the template directly, but that's a bit of an undesirable solution. I would rather keep it within the django application and even better have the js run only on specific plugins.
Any thoughts are appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在
CMSPluginBase
子类上设置change_form_template
,因为CMSPluginBase
是django.contrib.admin.options.ModelAdmin< 的子类/代码>。
You can set the
change_form_template
on yourCMSPluginBase
subclass, asCMSPluginBase
is a subclass ofdjango.contrib.admin.options.ModelAdmin
.