Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 795
Juanwolf Avatar asked Jul 26 '13 11:07

Juanwolf


People also ask

How do I allow all HTML tags in CKEditor?

If you want to allow all If you want to disable Advanced Content Filter, set CKEDITOR. config. allowedContent to true. All available editor features will be activated and input data will not be filtered.

How do you write HTML code in CKEditor?

Classic Editor with Default Source Editing AreaClick the Source button to display the HTML source of this text in the source editing area. Click the Source button again to return to the WYSIWYG view.

What is the output of CKEditor?

CKEditor 4 offers a flexible output formatting system that gives developers full control over what the HTML code produced by the editor will look like. It is possible to define: When to indent tags (each tag may have a different configuration) and which indentation method to use (tabs, spaces).


1 Answers

Try this in your template:

<div id="post">
    <h1> {{ post.title }}</h1>
    <p>{{post.content|safe}}</p>
    <i>{{post.date}}</i>
</div>
like image 200
otaviosoares Avatar answered Sep 30 '22 14:09

otaviosoares