Using safe filter in Django for rich text fields

后端 未结 4 1196
半阙折子戏
半阙折子戏 2021-01-11 14:33

I am using TinyMCE editor for textarea fileds in Django forms.

Now, in order to display the rich text back to the user, I am forced to use the \"safe\" filter in Dja

4条回答
  •  借酒劲吻你
    2021-01-11 15:11

    You can use the template filter "removetags" and just remove 'script'.

    Note that removetags has been removed from Django 2.0. Here is the deprecation notice from the docs:

    Deprecated since version 1.8: removetags cannot guarantee HTML safe output and has been deprecated due to security concerns. Consider using bleach instead.

提交回复
热议问题