简体   繁体   English

TinyMCE Django 框架

[英]TinyMCE Django Framework

I am using the TinyMCE editor for the admin part of my website.我正在使用 TinyMCE 编辑器作为我网站的管理部分。 The editor seems like it is installed correctly but after saving a post and displaying it on the main page it shows the raw html instead of rendering it.编辑器似乎安装正确,但在保存帖子并将其显示在主页上后,它显示原始 html 而不是呈现它。

More specifically it shows更具体地说,它显示

在此处输入图片说明

If it helps I used HTMLField in the model如果有帮助,我在模型中使用了 HTMLField

when you want to display html stored in a model you need to mark it as safe (if it is of course) for it to bypass the XSS protection see https://docs.djangoproject.com/en/1.10/ref/templates/builtins/#safe当您想显示存储在模型中的 html 时,您需要将其标记为安全(如果是的话)以绕过XSS保护,请参阅https://docs.djangoproject.com/en/1.10/ref/templates/内置/#safe

Marks a string as not requiring further HTML escaping prior to output.将字符串标记为在输出之前不需要进一步的 HTML 转义。 When autoescaping is off, this filter has no effect.当自动转义关闭时,此过滤器不起作用。

example for your template您的模板示例

{{ model.attribute|safe}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM