RichText Editor in Django Admin Site

RichText Editor in Django Admin Site
Photo by Chronis Yan on Unsplash

I wanted to add a rich text editor within django administrator. It is not that hard to add a rich text editor, as there are editors like CKeditor, Tinymce.

Download ckeditor file

There are multiple plugins for django like django-ckeditor or django-tinymce etc. It seemed very complicated to use for me. So what I did here is that I have downloaded ckeditor standard edition and extracted it in my Static folder and loaded the js file within templates>admin>base.html.

Now, using firebug, I retrieved the textarea name/id/class in which I wanted to add ckeditor using firebug (or from chrome/firefox: inspect elements). This process is simple, just load the page where your textarea(or any type of field) resides, open firebug and inspect that place.For example: lets say the model field I want to modify is named blogbody. So the element’s name in admin site was id_blogbody(auto generated). In case of using a form, the input will be like following:


blogbody= forms.CharField(
    widget=forms.TextInput(attrs={'id': 'id_blogbody'})

Generated text

<input id="id_blogbody" ... />

Then go to base.html and add this script:

  //in this example CKEDITOR.replace( '#id_blogbody' )

Now reload the page from admin site and a textfield with rich text editor will be generated!

Last updated: Jul 13, 2024

← Previous
Django Translation Using .PO File

This post is deprecated. Please follow the official documentation. When comes to using multiple …

Next →
Syncdb vs Migration

Putting a stop to an age old argument between syncdb and migration in Django.

Share Your Thoughts
M↓ Markdown