I'm using CKEditor rich text field for my Django blog app. But not getting the desired output. If I write some heading text, on the front end the output is <h1> Hello </h1>
. But I don't want heading tags, I also tried to striptags but in that case, the output is not heading it is simple paragraph text
index.html
{% for posts in post %}
<div>{{posts.content|striptags}}</div>
{% endfor %}
Rich text model
content = RichTextField(blank = True ,null = True)
I guess you want the safe
filter, which tells django you know you are doing something a little bit dangerous, and it should not try to protect you.
{% posts.content|safe %}
that will actually render the html (including any malicious javascript a user may have entered (ie i would strongly recomend using a package like bleach
or html-sanitizer
to only allow specific html tags)