Unescaping HTML in Django

2020-03-02 05:58发布

I have html encoded text which reads like this:

RT <a href="http://twitter.com/freuter">@freuter</a>... 

I want this displayed as html but I am not sure if there is a filter which i can apply to this text to convert the html-encoded text back to html ...

can someone help?

3条回答
放我归山
2楼-- · 2020-03-02 06:26
再贱就再见
3楼-- · 2020-03-02 06:31

As Daniel says, use the {{ tweet|safe }} filter in the html, or mark it safe from the views.

Use django.template.mark_safe()

查看更多
狗以群分
4楼-- · 2020-03-02 06:36

Try the |safe filter if you want to render all HTML.

查看更多
登录 后发表回答