CKEditor shows me html code
Asked Answered
N

1

8

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.

Naylor answered 26/7, 2013 at 11:54 Comment(0)
F
24

Try this in your template:

<div id="post">
    <h1> {{ post.title }}</h1>
    <p>{{post.content|safe}}</p>
    <i>{{post.date}}</i>
</div>
Friulian answered 26/7, 2013 at 12:10 Comment(1)
Osm...Thanks @otavisoaresEctopia

© 2022 - 2024 — McMap. All rights reserved.