Search code examples
djangockeditordjango-ckeditor

CKEditor shows me html code


I tried to use the CKEeditor for my django project but when i add a new item which uses this editor, I see the html code.

I used it like this :

My model :

class Article(models.Model):
    title = models.CharField(max_length=100, unique=True)
    slug = models.SlugField(max_length=100, unique=True)
    category = models.ForeignKey('Category')
    content = RichTextField()
    date = models.DateTimeField(auto_now = True)
    online = models.BooleanField()

my url : url(r'^ckeditor/', include('ckeditor.urls')),

my view :

def view_post(request, slug):
    return render_to_response('website/view_post.html',
    {
        'post': get_object_or_404(Article, slug=slug),
    },
    context_instance = RequestContext(request)
)

and my template :

<div id="post">
    <h1> {{ post.title }}</h1>
    <p>{{post.content}}</p>
    <i>{{post.date}}</i>
</div>

Please help.

Thanks for your answers.


Solution

  • Try this in your template:

    <div id="post">
        <h1> {{ post.title }}</h1>
        <p>{{post.content|safe}}</p>
        <i>{{post.date}}</i>
    </div>