如何在Djangocms中使用iframes

2024-06-15 21:49:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在寻找一个好的解决方案,使最终用户能够在模板占位符中插入iframes(Soundcloud)。我考虑过使用djangocms txt ckeditor插件。 在documentation中,它说要使用可配置的消毒剂来完成此操作:

djangocms-text-ckeditor uses html5lib to sanitize HTML to avoid security issues >and to check for correct HTML code. Sanitisation may strip tags usesful for some >use cases such as iframe; you may customize the tags and attributes allowed by >overriding the TEXT_ADDITIONAL_TAGS and TEXT_ADDITIONAL_ATTRIBUTES settings:

TEXT_ADDITIONAL_TAGS = ('iframe',)
TEXT_ADDITIONAL_ATTRIBUTES = ('scrolling', 'allowfullscreen', 'frameborder')

我确实编辑了设置.py在我的项目中重新启动了我的web服务器(nginx)。但消毒剂仍在包装它以避免html插入。在

我想避免只为这个目的而编写一个SoundCloud插件。在

欢迎提出任何建议。在


Tags: andthetotext插件ckeditorforhtml
1条回答
网友
1楼 · 发布于 2024-06-15 21:49:52

正如@yakky在评论中建议的那样,我确实更新了Django环境,在2.8.1版中使用了“djangocms_text_ckeditor”。在

在我的设置.py,效果很好:

TEXT_ADDITIONAL_TAGS = ('iframe',)
TEXT_ADDITIONAL_ATTRIBUTES = ('scrolling', 'allowfullscreen', 'frameborder', 'src', 'height', 'width')

(soundcloud)iframe出现了,没有出现进一步的问题。在

请注意:更新环境可能会导致失败。在开发环境中总是先尝试。在

相关问题 更多 >