Including HTML variable in Django template without escaping

13,249

Solution 1

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

Use django.template.mark_safe()

Solution 2

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

Solution 3

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

I think this answers your querstion.

Share:
13,249
demos
Author by

demos

Updated on July 22, 2022

Comments

  • demos
    demos almost 2 years

    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?

  • bjunix
    bjunix almost 12 years
    But first check if the content is really safe. I would not blindly trust tweets directly from twitter's api for example.