修改django-cms‘添加插件’基于每个插件的模板?

发布于 2024-10-17 14:38:50 字数 339 浏览 6 评论 0原文

我特别讨论的模板是用户向页面添加插件时使用的模板。无论是在管理区域,还是直接修改页面时,都使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浪推晚风 2024-10-24 14:38:50

您可以在 CMSPluginBase 子类上设置 change_form_template,因为 CMSPluginBasedjango.contrib.admin.options.ModelAdmin< 的子类/代码>。

You can set the change_form_template on your CMSPluginBase subclass, as CMSPluginBase is a subclass of django.contrib.admin.options.ModelAdmin.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文