Chanwoo Ahn
Chanwoo Ahn

Reputation: 334

tags of content written by django_summernote is exposed, not applied

I start using Django for personal blog building, and just install django_summernote as an editor.

However when I get the text in html templets, the html tags of main articles are exposed, not applied properly. It looks like below.

Here is the main text. 
Hellow World! First Post <h1><span style="font-family: Arial;">Hello, 
World!</span></h1><p><span style="font-family: Arial;">This is my first 
post.</span></p><p><br></p> 

Where the templet is like below.

<div id="middle_canvas">
    Here is the main text. <br>

    {% for post in recent_posts %}
        {{ post.title }}
        {{ post.text }} <br><br>
    {% endfor %}
</div>

Also, the Post model is like below.

class Post(models.Model):
    author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
    title = models.CharField(max_length=200)
    text = models.TextField()
    created_date = models.DateTimeField(
        default=timezone.now)
    published_date = models.DateTimeField(
        blank=True, null=True)

    def publish(self):
        self.published_date = timezone.now()
        self.save()

    def __str__(self):
        return self.title

I have no idea where to check.

Upvotes: 0

Views: 121

Answers (1)

Chanwoo Ahn
Chanwoo Ahn

Reputation: 334

Solved I used safe filter like below.

{{post.title | safe}}

Upvotes: 1

Related Questions