Django-tinymce in Django Admin - “can't find variable: tinyMCE”

旧时模样 提交于 2019-12-14 03:59:40

问题


I'm trying to use django-tinymce to edit fields in django admin.

I've the app installed in my virtualenv (django-tinymce==1.5.1b4). It's listed in my installed apps -

INSTALLED_APPS = (
    #...

    'tinymce',

    #...
)

My settings includes the following

TINYMCE_DEFAULT_CONFIG = {
'theme': "advanced",
'theme_advanced_toolbar_location': "top",
'theme_advanced_buttons1': "bold,italic,underline,separator,"
    "bullist,separator,outdent,indent,separator,undo,redo",
'theme_advanced_buttons2': "",
'theme_advanced_buttons3': "",
}

TINYMCE_SPELLCHECKER = True
TINYMCE_COMPRESSOR = True

And I've got the files available at /MEDIA_ROOT/js/tiny_mce (the default).

My models look like -

from tinymce import models as tinymce_models

class MyModel(models.Model)

    post = tinymce_models.HTMLField()

When I go to the model admin page, the field appears as a normal text field and my browser tells me there's an error on the inline js script for the field. It says it doesn't recognise the variable tinyMCE. It doesn't look like the page is even trying to load the js file (I'm getting no 404's - I can't see any sign of anything being loaded).

I'm not sure what I'm missing..


回答1:


  1. Have You, Sir, done python manage.py collectstatic ?
  2. What value variable in settings.py is in TINYMCE_JS_ROOT and TINYMCE_JS_URL
  3. If variable TINYMCE_JS_URL is not set check if You, Sir, have file at /MEDIA_ROOT/js/tiny_mce/tiny_mce.js. If not, try to copy manually from django-tinymce's egg.



回答2:


OK, looks like it might have been a bug in the django_tinymce code. I've reverted to 1.5.1b2 and everything works as expected. Guess I should look into filing a bug report.



来源:https://stackoverflow.com/questions/14238501/django-tinymce-in-django-admin-cant-find-variable-tinymce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!