1👍
✅
Assuming, that you have already installed the package using pip install django-ckeditor
and also included it in INSTALLED_APPS
list in your settings.py
file.
Try to use {{ form.media }}
tag which include the necessary scripts and stylesheets, so in the template:
{% block main %}
<div class="blocker" style="height: 100px;"></div>
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
{{ form.media }}
<button type="submit">Absenden</button>
</form>
{% endblock %}
In your forms.py
, import the CKEditorWidget
and use it to override the default widget for the content field, like so:
from ckeditor.widgets import CKEditorWidget
class Create(forms.ModelForm):
content = forms.CharField(widget=CKEditorWidget())
title = forms.CharField(label='title', max_length=100)
class Meta:
model = Post
fields = ['title', 'content']
Source:stackexchange.com