TinyMCE

Warning: at present moment (11/26/2005) the Admin (formerly "The new admin") prefixes all js paths with /media/ - don't forget to take it into account when you decide where to put (or link) your JavaScript files. Ticket #914 is filed to resolve the issue.

There are several free WYSIWYG editors, which can be used with Django's admin pages. Some overview and first hand experience can be found ​here.

Mode "textareas" instructs TinyMCE to convert all textareas to WYSIWYG editors. I use the advanced theme, and practically all standard plugins, which don't require server support. In inline mode you have minimalistic toolbar with the most essential tools. When you switch to full-screen mode (tool's icon looks like a monitor), you have practically all tools available for advanced editing. You can look up all options in ​TinyMCE Documentation.

Basically js option includes tuple items as JavaScript files in the header of CRUD pages for this model (see ​Django Model Reference / Admin Options). The first script is the main TinyMCE file. If you use TinyMCE compressor, include '/tiny_mce/tiny_mce_gzip.php' instead. The second script is your configuration file created in step #2.

MEDIA_URL will be prepended to the above urls, so adjust your paths accordingly.

Using TinyMCE with flatpages (oldforms)

If you want to use TinyMCE in the admin's textarea for flatpages this thing is a little bit different because you don't have direct access to the model (unless you modify the contrib code which would cause difficulties when upgrading Django). So one way of doing this is to extend the flatpage's admin template.

To do so you need to:

Create the directory <your_template_dir>/admin_copies/

Copy <your_django_source>/contrib/admin/templates/admin/change_form.html to <your_template_dir>/admin_copies/ This is needed because you are going to extend it and can't access the admin template directly from your local template (acctually a symlink would work fine if you're working in some *nix)

Create the directory <your_template_dir>/admin/flatpages/flatpage/

Create a template in that directory called change_form.html that extends the original admin template

Create your text using conventional WYSIWYG editor with all niceties (e.g., Word) and paste the result to TinyMCE.

Go to HTML mode to see generated code. You can change it here to make it perfect.

If you find problems while using certain tags in the editor (like all newlines between <pre> tags being substituted by </pre><pre>), just add to the file textareas.js the line remove_linebreaks : false, This problem arises because the option ​remove_linebreaks is enabled by default.

If you want to enlarge the default textarea provided by django (and you don't want to wait for this ​http://code.djangoproject.com/ticket/2596) add an onpageload callback to your init call (​onpageload). Called after pageload but before tinymce initialisation so you can change textarea sizes in the callback.

Alternatively you can change the default textarea size by using:

tinyMCE.init({
...
width : "800",
height : "500",

If you are a Safari user and TinyMCE isn't loading properly make sure that you have all the plugins specified in your textareas.js file. The plugins listed on the textareas.js file for this wikipage include plugins that are not included with the default TinyMCE download. This issue appears to only occur in Safari on OSX.