Issue
The problem is that I want to show the content of a Post in the template but I don't know how
The model of Post is:
from ckeditor.fields import RichTextField
class Post(models.Model):
...
content = RichTextField(verbose_name='contenido')
...
And in the template I have a for to show all the post that is like this:
{% for post in posts %}
...
{{ post.content }}
...
{% endfor %}
But when I see the page in the browser shows this: < p > Post content < /p >
Instead of this: Post content
Solution
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.
Answered By - tdsymonds
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.