Welcome to the django-tinymce documentation

django-tinymce is a Django application that contains a widget to render a form field as a TinyMCE editor.

Quickstart

Make sure staticfiles application is properly configured (TinyMCE is bundled with django-tinymce and uses staticfiles to automatically serve TinyMCE files).

  1. Install django-tinymce using pip (or any other way to install python package) from PyPI.

    $ pip install django-tinymce
    
  2. Add tinymce to INSTALLED_APPS in settings.py for your project:

    INSTALLED_APPS = (
        ...
        'tinymce',
        ...
    )
    
  3. Add tinymce.urls to urls.py for your project:

    urlpatterns = patterns('',
        ...
        (r'^tinymce/', include('tinymce.urls')),
        ...
    )
    
  4. Add a custom profile if needed in settings.py. A sample profile is shown below, for all the available options check http://www.tinymce.com/wiki.php/Configuration

    TINYMCE_PROFILE = {
        'theme': 'modern',
        'plugins': 'noneditable advlist autolink link lists charmap hr searchreplace wordcount visualblocks visualchars code insertdatetime save table contextmenu directionality paste textcolor',
        'toolbar': 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | forecolor backcolor | upload_button',
        'noneditable_leave_contenteditable': 'true',
        'setup': 'addCustomButtons',
        'content_css': os.path.join(STATIC_URL, "mycss/tinymce.css"),
        'relative_urls': False,
        'remove_script_host': True,
        'document_base_url': APP_HOST_URL,
        'removed_menuitems': 'newdocument'
    }
    
  5. Use HTMLField where you would use TextField (or check Usage for alternatives).

    from django.db import models
    from tinymce.models import HTMLField
    from myproject.settings import TINYMCE_PROFILE
    
    class MyModel(models.Model):
        my_field = HTMLField(profile=TINYMCE_PROFILE)
    

The django-tinymce code is licensed under the MIT License. See the LICENSE.txt file in the distribution. Note that the TinyMCE editor is distributed under its own license. Note that django-tinymce and TinyMCE licenses are compatible (although different) and we have permission to bundle TinyMCE with django-tinymce.