2

我正在尝试按照本教程让 tinymce 与 django 和 zinnia 一起工作。它不工作,所以我试图做“测试”,但是当我运行时得到这个错误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

谢谢你。

4

3 回答 3

5

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

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

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

django-tinymce urls.py 中有一些硬编码路径,假设目录被命名为“tiny_mce”,而实际上它们被命名为“tinymce”,因此我不得不重命名它们,或者你可以更改 django-tinymce 中的硬编码路径网址.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")
于 2014-02-26T20:56:00.783 回答
2

简单地关闭终端,然后重新启动应用程序再次为我修复了它(无需配置任何额外内容)。我按照这里的说明进行操作:

  1. 点安装 django-tinymce
  2. 添加tinymce到 'settings.py' 的 INSTALLED_APPS
  3. 添加(r'^tinymce/', include('tinymce.urls')),到 urls.py 中的 urlpatterns
  4. 做一个python manage.py syncdb (不确定是否需要)
  5. 在终端:$ export DJANGO_SETTINGS_MODULE='testtinymce.staticfiles_settings'
  6. 做另一个python manage.py syncdb以防万一,然后python manage.py runserver
  7. 然后,当我尝试打开浏览器时收到错误消息:http://localhost:8000/admin/myapphere
  8. 我重新启动了终端,为了以防万一,做了一个“收集静态”,然后做了python manage.py runserver,它工作了(我能够看到新字段)
于 2014-09-01T19:05:55.837 回答
1

最新版本的 tinymce 具有不同的配置。而不是像 from tinymce import HTMLField 那样导入 HTMLField 而是 from tinymce.models import HTMLField

于 2020-05-29T12:03:42.283 回答