Django framework in rich text editor tinymce

1. Install rich text module

pip install tinymce

 

2. Django projects registered to add configuration.

Setting application registration file

'tinymce',

Adding tinymce basic settings (Advanced - length 600 Width -400)

TINYMCE_DEFAULT_CONFIG = {
    'theme': 'advanced',
    'width': 600,
    'height': 400,
}

 3. urls Configuration

Add tinymce configuration

url(r'^tinymce/', include('tinymce.urls')),

 

4.models call

# Import module 
from tinymce.models Import htmlfile 

# call model class 
ricetext = htmlfile (= the verbose_name ' Rich Text ' )

 

After generating the migration file migration, and required for registration in the relevant admin module, you can add the information to use rich text in the background.

 

## rich text format are stored as HTML tags in the database, use should pay attention escape.

 

Guess you like

Origin www.cnblogs.com/jrri/p/11514233.html