I
I
Ilya2015-12-26 01:38:22
Django
Ilya, 2015-12-26 01:38:22

Why after adding text using ckeditor, it is not displayed correctly?

Added ckeditor, it is displayed normally in the admin panel. Let's say I write an article for a blog, publish it and format it there. I save and view the article and it is displayed with html tags.
That is like this:

<address><strong>ssl on;</strong></address> <address><strong>&nbsp;&nbsp;&nbsp; ssl_stapling on;<br />

Do I need to somehow specify ckeditor in html?
Because my posts are displayed like this, {{ post.content }}
I connected like this.
Models
class Post(models.Model):
    title = models.CharField(max_length=255, unique=True)
    datetime = models.DateTimeField(u'Date')
    anonse = RichTextField()
    content = RichTextField()
    slug = models.SlugField(verbose_name = u'URL',primary_key=True, max_length=250, unique=True)
    category = models.ForeignKey(Category,verbose_name=u'Category')

    def __str__(self):
        return self.content

    def get_absolute_url(self):
        return '{}'.format(self.slug)

views
class PostDetail(DetailView):
    model = Post
    context_object_name = 'post'
    slug_field = 'slug'

Or tell me which editor you use.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zelsky, 2015-12-26
@nuBacuk

in template {{ post.content | safe ))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question