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.
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.
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.
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).
Try this in your template:
<div id="post">
<h1> {{ post.title }}</h1>
<p>{{post.content|safe}}</p>
<i>{{post.date}}</i>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With