|
This section describes how to install the django-tinymce application in your Django project.
The django-tinymce application requires Django version 1.0 or higher. You will also
need TinyMCE version 3.0.1 or higher and a language pack for every
language you enabled in settings.LANGUAGES
. If you use the django-filebrowser
application in your project, the tinymce application can use it as a browser
when including media.
If you want to use the spellchecker plugin using the supplied view (no PHP
needed) you must install the PyEnchant package and dictionaries for your
project languages. Note that the Enchant needs a dictionary that exactly
matches your language codes. For example, a dictionary for code 'en-us'
will not automatically be used for 'en'
. You can check the availability of
the Enchant dictionary for the 'en'
language code using the following
Python code:
import enchant
enchant.dict_exists('en')
Note that the documentation will use ‘TinyMCE’ (capitalized) to refer the editor itself and ‘django-tinymce’ (lower case) to refer to the Django application.
Install django-tinymce using pip (or any other way to install python package) from PyPI. If you need to use a different way to install django-tinymce you can place the tinymce
module on your Python path. You can put it into your Django project directory or run python setup.py install
from a shell.
pip install django-tinymce
Add tinymce
to INSTALLED_APPS in settings.py
for your project:
INSTALLED_APPS = (
...
'tinymce',
...
)
Add tinymce.urls
to urls.py
for your project:
urlpatterns = patterns('',
...
(r'^tinymce/', include('tinymce.urls')),
...
)
Verify that everything is installed and configured properly:
Setup an isolated environment with virtualenv and activate environment:
virtualenv --no-site-packages env
. env/bin/activate
Install required packages:
pip install Django django-tinymce
Setup environment variable DJANGO_SETTINGS_MODULE
:
export DJANGO_SETTINGS_MODULE='testtinymce.settings'
Setup test database (it will be created in current folder):
django-admin syncdb
Run Django runserver command to verify results:
django-admin runserver
Open this address in a browser:
http://localhost:8000/admin/testapp/testpage/add/
If you see TinyMCE instead of standard textarea boxes everything is working fine, otherwise check installation steps.
The application can be configured by editing the project’s settings.py
file.
TINYMCE_JS_URL
(default: settings.MEDIA_URL + 'js/tiny_mce/tiny_mce.js'
)The URL of the TinyMCE javascript file:
TINYMCE_JS_URL = os.path.join(MEDIA_URL, "path/to/tiny_mce/tiny_mce.js")
TINYMCE_JS_ROOT
(default: settings.MEDIA_ROOT + 'js/tiny_mce'
)The filesystem location of the TinyMCE files. It is used by the compressor (see below):
TINYMCE_JS_ROOT = os.path.join(MEDIA_ROOT, "path/to/tiny_mce")
TINYMCE_DEFAULT_CONFIG
(default: {'theme': "simple", 'relative_urls': False}
)mce_attrs
parameter for the widget.TINYMCE_SPELLCHECKER
(default: False
)spellchecker
to the TinyMCE plugin list yourself, it is not added
automatically.TINYMCE_COMPRESSOR
(default: False
)TINYMCE_FILEBROWSER
(default: True
if 'filebrowser'
is in INSTALLED_APPS
, else False
)Example:
TINYMCE_JS_URL = 'http://debug.example.org/tiny_mce/tiny_mce_src.js'
TINYMCE_DEFAULT_CONFIG = {
'plugins': "table,spellchecker,paste,searchreplace",
'theme': "advanced",
'cleanup_on_startup': True,
'custom_undo_redo_levels': 10,
}
TINYMCE_SPELLCHECKER = True
TINYMCE_COMPRESSOR = True