[Django]-Django-CKeditor: How to show RichTextFields in templates

15👍

You need to mark the content as safe. So change your template to:

{% for post in posts %}
    ...
    {{ post.content|safe }}
    ...
{% endfor %}

By default HTML is not escaped and so is displayed as text, which is why you’re seeing the <p> tags. You need to mark the field as safe so that Django renders it as HTML. See the documentation for more info.

1👍

{{article.body|safe}}

or

{{article.body|truncatechars:150|safe}}

or

{{article.body|truncatewords:25|safe}}
👤Gata

Leave a comment