如何在django-cms中使用iframe [英] How to use iframes in django-cms

查看:427
本文介绍了如何在django-cms中使用iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个很好的解决方案,使终端用户可以在模板占位符中插入iframe(Soundcloud)。我想到了使用djangocms-txt-ckeditor插件。
其中文档说它使用可配置的消毒剂来实现这一点: / p>

I am looking for a good solution to make it possible for endusers to insert iframes (Soundcloud) in a template placeholder. I thought about using the djangocms-txt-ckeditor plugin. In it documentation it says to use the configurable sanitizer to accomplish this:


djangocms-text-ckeditor使用html5lib清理HTML以避免安全问题>并检查正确的HTML代码。 Sanitation可能会剥夺一些使用案例的标签,如iframe;您可以自定义覆盖TEXT_ADDITIONAL_TAGS和TEXT_ADDITIONAL_ATTRIBUTES设置的标签和属性:

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')

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


我在我的项目中编辑了settings.py,并重新启动了我的webserver(nginx)。但是,消毒剂仍然包装它以避免html插入。

I did edit the settings.py in my project like that and restarted my webserver (nginx). But the sanitizer is still wrapping it to avoid html-insertion.

我想避免为此而编写一个SoundCloud插件。

I would like to avoid writing a SoundCloud plugin only for this purpose.

欢迎任何建议。

推荐答案

根据@yakky在评论中的建议,我更新了Django环境,在2.8.1版中使用djangocms_text_ckeditor。

As suggested by @yakky in the comments I did update the Django environment to use "djangocms_text_ckeditor" in version 2.8.1.

在我的settings.py中使用此设置时,效果非常好:

While using this settings in my settings.py, it works great:

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

(soundcloud)iframe显示,没有进一步的问题发生。

The (soundcloud) iframe shows up and no further problems did occur.

请注意:更新您的环境可能会导致故障。始终在开发环境中尝试。

Be aware: Updating your environment can cause failures. Always try first within a development environment.

这篇关于如何在django-cms中使用iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆