Unescaping HTML in Django

2020-03-02 05:44发布

问题:

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?

回答1:

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

Use django.template.mark_safe()



回答2:

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



回答3:

See: How do I perform HTML decoding/encoding using Python/Django?

I think this answers your querstion.