[Answer]-Using grappelli tinyMce in django didn't work

1πŸ‘

βœ…

i find this is problem of the STATIC FILES path.
i got a sulotion about this
add MEDIA_ROOT in the settings.py:

MEDIA_ROOT=os.path.join(BASE_DIR,STATIC_URL.replace("/",""))

then and STATICFILES_DIRS

STATICFILES_DIRS=(
    MEDIA_ROOT,
)

Media Class in the ModelAdmin likes this:

class Media:
        js = ('/static/grappelli/tinymce/jscripts/tiny_mce/tiny_mce.js',
            '/static/grappelli/js/tinymce_setup/tinymce_setup.js',)

after all this runserver. it worked!

πŸ‘€JJ_Jacob

0πŸ‘

Everything is described on the Grappeli documentation: http://django-grappelli.readthedocs.io/en/latest/customization.html#using-tinymce

Grappelli already comes with TinyMCE and a minimal theme as well. In order to use TinyMCE, copy tinymce_setup.js to your static directory, adjust the setup (see TinyMCE Configuration) and add the necessary javascripts to your ModelAdmin definition (see ModelAdmin asset definitions):

class Media:
    js = [
        '/static/grappelli/tinymce/jscripts/tiny_mce/tiny_mce.js',
        '/static/path/to/your/tinymce_setup.js',
    ]

Using TinyMCE with inlines is a bit more tricky because of the hidden
extra inline. You need to write a custom template and use the inline
callbacks to

onInit: remove TinyMCE instances from the empty form.
onAfterAdded: initialize TinyMCE instance(s) from the form.
onBeforeRemoved: remove TinyMCE instance(s) from the form.
Note

TinyMCE with inlines is not supported by default. If our version of
TinyMCE does not fit your needs, add a different version to your
static directory and change the above mentioned ModelAdmin setup
(paths to js–files).

Warning

TinyMCE will be removed with version 3.0 of Grappelli, because TinyMCE
version 4.x comes with a decent skin.

πŸ‘€Przemek Nowak

Leave a comment