Integrating with Django TinyMCE — Django Stories v0.5 documentation

Django Stories v0.5 documentation

# Integrating with Django TinyMCE

- Table of Contents
- index
  modules
  next
  previous

# Integrating with Django TinyMCE

## Install django-tinymce

Django-tinymce makes it very easy to include a GUI text editor for any textarea.

1. Install a special fork of django-tinymce from github

       pip install git+http://github.com/justquick/django-tinymce.git#egg=tinymce

2. Download TinyMCE and copy the contents of the `jscript` directory into a `js` directory within your `MEDIA_ROOT` directory.

       /myproject
           /apps
           /static
               /css
               /img
               /js
       -------->   /tinymce

3. Add `tinymce` to your `INSTALLED_APPS` setting.

       INSTALLED_APPS = (
           ...
           'tinymce',
       )

4. Add `(r'^tinymce/', include('tinymce.urls')),` to your `urls.py`.

       urlpatterns = patterns('',
           ...
           (r'^tinymce/', include('tinymce.urls')),
           ...
       )

5. Add the settings for tinymce. The configuration of plugins and tools shown here is just an example. See the django-tinymce docs and TinyMCE Manual for more information. For example:

       TINYMCE_DEFAULT_CONFIG = {
           'theme': "advanced",
           'relative_urls': False,
           'plugins': "safari,paste,advimage,preview",
           'theme_advanced_toolbar_location' : "top",
           'theme_advanced_toolbar_align' : "left",
           'theme_advanced_buttons1' : "formatselect,bold,italic,underline,separator,bullist,numlist,separator,undo,separator,link,unlink,separator,charmap,image,paste,pasteword,separator,code,preview",
           'theme_advanced_buttons2' : "",
           'theme_advanced_buttons3' : "",
           #'skin': 'thebigreason',
               'theme_advanced_statusbar_location' : "bottom",
               'width': "600",
               'height': "600",
       }

6. Add the `TINYMCE_ADMIN_FIELDS` setting:

       TINYMCE_ADMIN_FIELDS = {
           'stories.story': ('body',),
       }

   You can add other fields for other models in here as well, for example:

       TINYMCE_ADMIN_FIELDS = {
           'stories.story': ('body',),
           'flatpages.flatpage': ('content',),
       }