user984003
user984003

Reputation: 29597

Django: show raw html (from database) as html, not rendered

I have created a rich text area using tinymce. I have now saved this to my database and want to display it. It gets saved in the database as html with tags, etc. To display it I have tried:

In views:

content = get_content_from_db()
render_to_response("template.html", {"content":content})

In template:

{{content}}

This shows the content with the tags like so:

<strong>My text</strong>

instead of just displaying the text as bold.

I have also tried using the verbatim tag, but this (doh!) displays as:

{{content}}

How should I do this? Do I need to save it differently? I save it the way I save any other TextArea except the field is a blob.

Upvotes: 39

Views: 27766

Answers (1)

DrTyrsa
DrTyrsa

Reputation: 31991

Use safe filter

{{ content|safe }}

Upvotes: 83

Related Questions