Django-Tinymce导入错误

时间:2013-06-14 16:23:33

标签: python django tinymce django-tinymce

我正在努力跟随this tutorial关注让你和django和百日草一起工作。它不起作用,所以我试图进行“测试”,但在运行django-admin.py syncdb时出现此错误。我该如何解决这个问题?

$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

谢谢。

3 个答案:

答案 0 :(得分:4)

我发现django-tinymce文档已经过时,即部分错误。

我发现不同版本的tinymce和django-tinymce包不兼容。

我解决了将一些变量添加到我的project / settings.py并更改了tinymce目录和文件名。

django-tinymce urls.py中有一些硬编码路径,假设目录名为“tiny_mce”,实际上它们被命名为“tinymce”,因此我不得不重命名它们,或者你可以改变硬编码路径django-tinymce的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")

答案 1 :(得分:2)

终端的简单关闭,然后重新启动应用程序再次为我修复它(无需配置额外的任何东西)。我按照说明here

  1. pip install django-tinymce
  2. tinymce添加到&#39; settings.py&#39;
  3. 的INSTALLED_APPS
  4. (r'^tinymce/', include('tinymce.urls')),添加到urls.py
  5. 中的urlpatterns
  6. python manage.py syncdb(不确定是否需要)
  7. 在终端:$ export DJANGO_SETTINGS_MODULE='testtinymce.staticfiles_settings'
  8. 为了以防再做一个python manage.py syncdb,然后是python manage.py runserver
  9. 当我尝试打开浏览器时,我收到了错误:http://localhost:8000/admin/myapphere
  10. 我重新启动了终端,做了一个“收集静态”的信息。以防万一,然后python manage.py runserver并且它有效(我能够看到新的字段)

答案 2 :(得分:1)

最新版本的tinymce具有不同的配置。 而不是像导入HTMLField 从tinymce导入HTMLField 反而 从tinymce.models导入HTMLField