2015-04-05 62 views
0

我在我的django項目中添加了Tinymce。但是現在我無法啓動django測試服務器。我收到以下錯誤。Django Tincymce,AttributeError:'NoneType'對象沒有屬性'endswith'

(postjust)erkans-MacBook-Air:postjust erkan$ python manage.py runserver 
Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/erkan/Dev/Python/virtualenvs/postjust/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line 
    utility.execute() 
    File "/Users/erkan/Dev/Python/virtualenvs/postjust/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute 
    django.setup() 
    File "/Users/erkan/Dev/Python/virtualenvs/postjust/lib/python2.7/site-packages/django/__init__.py", line 21, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "/Users/erkan/Dev/Python/virtualenvs/postjust/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate 
    app_config.import_models(all_models) 
    File "/Users/erkan/Dev/Python/virtualenvs/postjust/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models 
    self.models_module = import_module(models_module_name) 
    File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/Users/erkan/Dev/Python/virtualenvs/postjust/lib/python2.7/site-packages/tinymce/models.py", line 6, in <module> 
    from tinymce import widgets as tinymce_widgets 
    File "/Users/erkan/Dev/Python/virtualenvs/postjust/lib/python2.7/site-packages/tinymce/widgets.py", line 10, in <module> 
    import tinymce.settings 
    File "/Users/erkan/Dev/Python/virtualenvs/postjust/lib/python2.7/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/erkan/Dev/Python/virtualenvs/postjust/bin/../lib/python2.7/posixpath.py", line 77, in join 
    elif path == '' or path.endswith('/'): 
AttributeError: 'NoneType' object has no attribute 'endswith' 

我在我的設置中有Static_Url。

我settings.py:

""" 
Django settings for postjust 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 = '[email protected](98(ew4kkociwv+2y(3799r*vug7-$g)e=6wsxigrk30=!' 

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

TEMPLATE_DEBUG = True 

ALLOWED_HOSTS = ['localhost','127.0.0.1'] 


# Application definition 

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

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', 
    'pages.context_processors.pages' 
) 

ROOT_URLCONF = 'postjust.urls' 

WSGI_APPLICATION = 'postjust.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/' 

我嘗試喲集static_url爲 '' 和 '/'。解決辦法是什麼 ?

回答

1

您需要在您的設置中使用STATIC_ROOT,而不僅僅是STATIC_URL。 Docs可以找到here

+0

是的感謝解決方案和文檔。有用。 – 2015-04-05 14:26:29