How to Install wysiwyg editor in your django project

with django-wysiwyg, you get different rich html text editors, making it easier to write article posts.
It supports TinyMCE, CKEditor, Redactor, Froala, yui and more

Follow the below steps to setup django-wysiwyg in your django project.


1. Install django-wysiwyg

pip install django-wysiwyg

2. Install you editor of choice. I will be installing ckeditor (you can install anyone of your choice)

pip install django-ckeditor

3. Now, add them in Installed app in settings.py like shown below.

INSTALLED_APPS = (
...
'django_wysiwyg',
'ckeditor'
)

4. and also add the following line in settings.py

DJANGO_WYSIWYG_FLAVOR = "ckeditor"

5. In your template add these lines where you would like the wysiwyg editor to appear.

{% load wysiwyg %}
{% wysiwyg_setup %}

<textarea id="foo"></textarea>

{% wysiwyg_editor "foo" %}

Done!

you can also add wysiwyg editor to django admin, follow these steps

Tip: In CKEditor every line you type gets wrapped around a p tag automatically. To disable it
 add this line in your ckeditor config.js file

config.enterMode = CKEDITOR.ENTER_BR;

Leave a Reply

Your email address will not be published.