Search code examples
djangotemplatesdjango-admindjango-tinymce

django tiny mce is normal text field instead of rich text formatting? a fix please. Settings included


I installed Django tiny mce however i am getting a normal text area in my admin. Can anyone help me to correct this to a rich text area where i can acces text formating?

here are my settings.py

 import os
PROJECT_DIR = os.path.dirname(__file__)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '[email protected]'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}



...
...
...
...    
...    
...    
...    
...    
...    
...    
...    
...    
...    
...
TINYMCE_JS_URL = '/media/js/tiny_mce/tiny_mce.js/'

# languages you want to translate into the CMS.

DEFAULT_PAGE_TEMPLATE = 'pages/generic.html'

PAGE_TEMPLATES = (
    ('pages/generic.html', 'Generic'),
 ('pages/index.html', 'Home Page'),
    ('pages/people.html', 'People'),

)

Solution

  • django-tinymce doesn't replace all textarea fields with TinyMCE editors, you have to use it explicitely either with HTMLField in your models:

    from django.db import models
    from tinymce import models as tinymce_models
    
    class MyModel(models.Model):
        my_field = tinymce_models.HTMLField()
    

    Or for third party apps by replacing the widgets in the admin, as explained in the documentation.