安装tinymce后的Django TypeError

时间:2014-11-13 12:58:40

标签: python django tinymce typeerror nonetype

安装tinymce并将其包含在settings.py中的INSTALLED_APPS后,当我尝试运行本地服务器时出现此错误:

(django) \mypath\ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\venv\django\lib\site-packages\django\core\management\__init__.py", line 385, in execute_f
rom_command_line
    utility.execute()
  File "C:\venv\django\lib\site-packages\django\core\management\__init__.py", line 354, in execute
    django.setup()
  File "C:\venv\django\lib\site-packages\django\__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\venv\django\lib\site-packages\django\apps\registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "C:\venv\django\lib\site-packages\django\apps\config.py", line 197, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Python27\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\venv\django\lib\site-packages\tinymce\models.py", line 6, in <module>
    from tinymce import widgets as tinymce_widgets
  File "C:\venv\django\lib\site-packages\tinymce\widgets.py", line 10, in <module>
    import tinymce.settings
  File "C:\venv\django\lib\site-packages\tinymce\settings.py", line 16, in <module>
    JS_ROOT = getattr(settings, 'TINYMCE_JS_ROOT',os.path.join(settings.STATIC_ROOT, 'tiny_mce'))
  File "C:\venv\django\lib\ntpath.py", line 64, in join
    result_drive, result_path = splitdrive(path)
  File "C:\venv\django\lib\ntpath.py", line 114, in splitdrive
    if len(p) > 1:
TypeError: object of type 'NoneType' has no len()

我不知道发生了什么,因为我甚至没有开始搞乱文件来实际使用项目中的tinymce。当我简单地删除&#39; tinymce&#39;从INSTALLED_APPS它恢复正常但事情是我真的需要tinymce。我确保多次使用pip安装了tinymce。这是我的settings.py的样子:

"""
Django settings for mysite project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '***'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'tinymce',
    'interface',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.core.context_processors.tz",
    "django.contrib.messages.context_processors.messages",
    "interface.context_processor.global_vars"
)

ROOT_URLCONF = 'mysite.urls'

WSGI_APPLICATION = 'mysite.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL = '/static/'

我很感激任何帮助,提前谢谢。

2 个答案:

答案 0 :(得分:2)

您似乎需要在settings.py中设置STATIC_ROOT / URL。

答案 1 :(得分:0)

尝试将TINYMCE_JS_ROOT设置为settings.py中的tinymce js文件夹。根据我从错误输出中可以看出的情况,此设置缺失。