Search code examples
pythondjangotinymcedjango-tinymce

Django-Tinymce Import Error


I am trying to follow this tutorial on getting tinymce working with django and zinnia. It's not working, so I am attempting to do "Testing" but get this error when I run django-admin.py syncdb. How do I fix this?

$django-admin.py syncdb
Traceback (most recent call last):
  File "/usr/local/bin/django-admin.py", line 5, in <module>
    pkg_resources.run_script('Django==1.5.1', 'django-admin.py')
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 505, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1245, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg/EGG-INFO/scripts/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg/django/core/management/__init__.py", line 453, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg/django/core/management/__init__.py", line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg/django/core/management/__init__.py", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg/django/conf/__init__.py", line 48, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.5.1-py2.7.egg/django/conf/__init__.py", line 134, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'testtinymce.staticfiles_settings' (Is it on sys.path?): No module named staticfiles_settings

Thank you.


Solution

  • I found out the django-tinymce documentation is outdated, i.e. partially wrong.

    What I discovered is that different versions of tinymce and django-tinymce packages are not compatible.

    I solved it adding some variables to my project/settings.py and altering the tinymce directory and file names.

    django-tinymce urls.py had some hardcoded paths in it which assumed the directories were named "tiny_mce" when in reality they were named "tinymce", hence I had to rename them, or alternatively you can change the hardcoded paths in django-tinymce's urls.py.

    # project setting.py
    STATIC_ROOT = os.path.join(BASE_DIR, "static")
    STATIC_JS_DIR = os.path.join(STATIC_DIR, "js")
    TINYMCE_JS_ROOT = os.path.join(STATIC_JS_DIR, "tiny_mce")
    TINYMCE_JS_URL = os.path.join(TINYMCE_JS_ROOT, "tiny_mce.js")
    #TINYMCE_JS_ROOT = os.path.join(STATIC_JS_DIR, "tiny_mce")
    #TINYMCE_JS_URL = os.path.join(TINYMCE_JS_ROOT, "tiny_mce.js")