Django runserver错误:+ =:' NoneType'不支持的操作数类型和' str'

时间:2015-07-03 15:31:34

标签: python django server

我正在运行一个用Django制作的本地开发项目。但是我不能让dev服务器启动:

(Gaia_database_env)FakeComputer:gaia_database_proj FakeUser$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/FakeUser/GoogleDrive/Sites/Gaia_database_env/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/FakeUser/GoogleDrive/Sites/Gaia_database_env/lib/python3.4/site-packages/django/core/management/__init__.py", line 312, in execute
    django.setup()
  File "/Users/FakeUser/GoogleDrive/Sites/Gaia_database_env/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/FakeUser/GoogleDrive/Sites/Gaia_database_env/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/Users/FakeUser/GoogleDrive/Sites/Gaia_database_env/lib/python3.4/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/Users/FakeUser/GoogleDrive/Sites/Gaia_database_env/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/Users/FakeUser/GoogleDrive/Sites/Gaia_database_env/lib/python3.4/site-packages/tinymce/models.py", line 6, in <module>
    from tinymce import widgets as tinymce_widgets
  File "/Users/FakeUser/GoogleDrive/Sites/Gaia_database_env/lib/python3.4/site-packages/tinymce/widgets.py", line 10, in <module>
    import tinymce.settings
  File "/Users/FakeUser/GoogleDrive/Sites/Gaia_database_env/lib/python3.4/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 "/Users/FakeUser/GoogleDrive/Sites/Gaia_database_env/bin/../lib/python3.4/posixpath.py", line 82, in join
    path += b
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str

我正在使用这个软件包进行虚拟环境:

(Gaia_database_env)FakeComputer:gaia_database_proj FakeUser$ pip freeze
Django==1.8.2
django-bootstrap3==6.1.0
django-tinymce==1.5.3
wheel==0.24.0

这就是我的settings.py:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'm6eu#pf_u$upk2qkizhp%gvc6wb%1(alhey8!hqkdzq%j%b4&('

# SECURITY WARNING: don't run with debug turned on in production!
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',
    'bootstrap3',
    'gaia_app'
)

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',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'gaia_database.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'gaia_database.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/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.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'CET'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

STATIC_URL = '/static/'

任何想法??

由于

1 个答案:

答案 0 :(得分:1)

自Django 1.7起,STATIC_ROOT默认为None,因此除非你设置它,否则TinyMCE将无法正确提供其JS文件。

你应该:

  • 设置TINYMCE_JS_ROOT
  • 设置STATIC_ROOT

现在,除非您将TINYMCE_COMPRESSOR设置为True(默认为False),否则不会使用这些设置,因此如果您不知道它们是什么,我建议您暂时将TINYMCE_JS_ROOT设置为"tiny_mce"

TinyMCE documentation有一些关于配置的信息,但它不是非常准确或有帮助的。 actual code that runs就在这里,here is where JS_ROOT is actually used