2015-07-03 92 views
2

我正在使用Django做了一個本地開發項目:+ =不支持的操作類型。但我不能有開發服務器啓動:的Django的runserver錯誤:「NoneType」和「海峽」

(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 

我正在變成一個虛擬的env這個包:

(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/' 

任何想法??

感謝

+0

@ nu11p01n73R老兄,如果你剛纔讀的例外,你可以看到他的呼喚os.path.join。我不認爲告訴他路徑+ = b失敗會幫助,除非他想重寫os.path.join函數。 – CrazyCasta

+0

@Bakaburg,是TinyMCE的你正在開發一個應用程序或某事有人做,你正在嘗試使用?我們可能需要查看tinymce/settings.py文件。 – CrazyCasta

+0

所以這個問題不在posixpath.py! TinyMCE是一款非常常見的基於HTML5的富文本編輯器。我應該在settings.py中尋找什麼? – Bakaburg

回答

1

由於Django的1.7,STATIC_ROOT默認爲None,所以除非你設置它,TinyMCE的將無法正常發揮其JS文件。

您應該:

  • TINYMCE_JS_ROOT
  • 設置STATIC_ROOT

現在,這些設置不會被使用,除非你也設置TINYMCE_COMPRESSORTrue(默認爲False ),所以如果你不知道它們是什麼,我建議你設置TINYMCE_JS_ROOT"tiny_mce"現在。


TinyMCE documentation對配置的一些信息,但它既不非常準確的還是很有幫助的。 actual code that runs在這裏,here is where JS_ROOT is actually used

+0

呃... ...我加TINYMCE_JS_ROOT =「tiny_mce」我的設置並沒有什麼改變。我也在我的問題中寫下了我的設置。我想,而不是寫下tiny_mce的路徑。但它在虛擬env python文件夾中。我不認爲我應該聲明該文件夾的完整絕對路徑... – Bakaburg

相關問題