Django TinyMCEWrapper v 0.4.2

About

We created Django TinyMCEWrapper to allow us to enable a TinyMCE widget on various third-party Django apps’ ModelAdmin, without having to fork the apps or re-do their ModelAdmin.

The process is flexible, simple and harmless. Django-TinyMCEWrapper redefines the ModelAdmin class after all admin classes are registered and overrides the widget used for the configured fields.

Contents

Installation

  1. Install using pip.

    pip install django-tinymcewrapper
    
  2. Add tinymcewrapper to your project’s INSTALLED_APPS.

    INSTALLED_APPS = (
        # ... other apps
        'tinymce',
        'tinymcewrapper',
    )
    

Dependencies

Django TinyMCE

Getting Started

  1. Install django-tinymcewrapper and django-tinymce.
  2. Configure django-tinymce
  3. Configure django-tinymcewrapper

Configuration

The ADMIN_FIELDS setting is a dictionary in the format {'app.model': <field configuration>}. There are two methods to specify field configuration: simple and custom.

Simple Configuration

The field configuration in the simple configuration is simply a tuple of strings containing the fields to add a TinyMCE widget in the admin. These fields will use all the defaults for django-tinymce.

TINYMCEWRAPPER_SETTINGS = {
    'ADMIN_FIELDS': {
        'simpleapp.simplemodel': ('description', 'long_description')
    },
}

Custom Configuration

For more control over how the TinyMCE widget is rendered, you can use a dict with the field names as keys and the value a dict that is passed as keyword arguments to the TinyMCE HTML widget.

TINYMCEWRAPPER_SETTINGS = {
    'ADMIN_FIELDS': {
       'simpleapp.simplemodel': {
          'description': {
             'attrs': {'cols': 80, 'rows': 30,},
             'mce_attrs': {'theme': 'advanced'}
          },
          'long_description': {},
       }
    },
}

Reference

Settings

ADMIN_FIELDS

ADMIN_FIELDS is a dictionary in the format {'app.model': <field configuration>}. <field configuration> is either a list or tuple

{'app.model': ('field', 'field2',),}

or the <field configuration> is a dict.

{'app.model': {
    'field1': {
        'attrs': {'cols': 80, 'rows': 30},
        'mce_attrs': {'theme': 'advanced'}
    },
    'field2': {} # default configuration
}}

For more information see Configuration.