Flobin Flobin - 1 year ago 72
Javascript Question

Django-tinymce not loading javascript

I have (tried to) set up django-tinymce in my Django project. However, in the inspector, I don’t see the tinymce.min.js being loaded.

This is in my settings:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = 'localhost:8123'

# TinyMCE configuration
TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, "articles/build/lib/node_modules/tinymce")
TINYMCE_JS_URL = os.path.join(TINYMCE_JS_ROOT, "tinymce.min.js")
'theme': "modern",
'toolbar': "undo redo | bold italic | bullist numlist | blockquote | removeformat",
'menubar': False,
'statusbar': False,
'schema': "html5",
'max_height': 500,
'max_width': 500,
'min_height': 100,
'min_width': 400

Removing the
and changing
does not change anything—still no tinymce js being loaded.

This is my file structure:

| |-styles
| |-scripts
| |-images
| |-css
| |-js
| |-img
| |-lib
| | |-package.json
| | |-node_modules
| | | |-tinymce
| | | | |-tinymce.js
| | | | |-more_tinymce_files_here

In my template I do have
{{ form.media }}
, but maybe that‘s the problem.

The full code with templates, settings, urls, etc. is available here.

How can I make sure that the tinymce javascript loads? Or: how can I debug this?

Answer Source

As it turns out, the error was in settings.py. The tinymce location needs to be set like this:

TINYMCE_JS_ROOT = "articles/build/lib/node_modules/tinymce"
TINYMCE_JS_URL = os.path.join(TINYMCE_JS_ROOT, "tinymce.js")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download