Django-tinymce in Django’s Admin App

In our previous post, we discussed Django-tinymce, a JavaScript WYSIWYG editor that converts an HTML textarea field into an editor instance.  Again, django-tinymce is a Django application that contains a widget that renders a form field as a TinyMCE editor. This is especially helpful when you have forms that require rich text editing.

But what about the admin panel? Can you have TinyMCE there, too?

In this post, we will discuss using TinyMCE in Django admin.

1. Get TinyMCE (if you haven’t yet, then see the previous post on django-tinymce).

2. Set your project to use the Django admin application.

3. Once you have both, go to your templates directory and create a folder named ‘admin’. This is where your tinyMCE comes in.

4. Create a new HTML file, base_site.html inside the admin folder, and inside it, copy and paste the following code:

As you can see from the code we have above, it is almost the same as when you put tinyMCE on any other HTML page in your project. What we did is that we replaced the default base_site.html of our admin app templates, and added our tinyMCE.

This is because (if you haven’t noticed already) TextFields in your django admin application are represented as <textarea></textarea> tags.