Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render html text from database inside a django template using template tags

I save a text into my database using django form, textarea widget and bootstrap wysiwyg, but when I try to render it into my template using just the variable name

{{ text }}, 

I get rendered just the text with html tags like this:
shows the rendering of html tags
what I want to do is show the formatted text in html.

like image 464
Angie Alejo Avatar asked Dec 19 '22 11:12

Angie Alejo


1 Answers

If you have the formatted HTML in your DB-field, and you absolutely sure is it safe, then try safe filter

{{ tablename.fieldname|safe }}

or

{{var|safe}}

See the doc.

like image 53
Y.N Avatar answered Dec 28 '22 08:12

Y.N