在settings.py中运行collectstatic时出现语法错误(Django 1.5.1)

时间:2013-07-29 16:47:58

标签: python django python-2.7 django-settings

我对Python / Django /编码绝对是全新的,所以我知道可能有一些超级简单的东西我不知道。任何帮助整理这将是很棒的。提前致谢。

当我运行python manage.py collectstatic时,我进入终端:

File "/Users/user/Desktop/mvp_landing/mvp_landing/settings.py", line 123
INSTALLED_APPS = (
             ^
SyntaxError: invalid syntax

在我的settings.py文件中,我在第123行,INSTALLED_APPS

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'south',
'join',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

这是文件的其余部分(减去db信息等):

MEDIA_ROOT = "os.path.join(os.path.dirname(os.path.dirname(__file___))", "static", "media"

MEDIA_URL = '/media/'

STATIC_ROOT = "os.path.join(os.path.dirname(os.path.dirname(__file__))", "static", "static-only"

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    "os.path.join(os.path.dirname(os.path.dirname(__file__))", "static", "static",
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

SECRET_KEY = 'xxxxxxxxx'

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

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

ROOT_URLCONF = 'mvp_landing.urls'

WSGI_APPLICATION = 'mvp_landing.wsgi.application'

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(os.path.dirname(__file__)), "static", "templates",
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'south',
    'join',   
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

1 个答案:

答案 0 :(得分:2)

您在前一行中缺少一个括号:

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(os.path.dirname(__file__)), "static", "templates",
)

我算了4个开口,但只有3个关闭;你没有关闭os.path.join()电话:

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname(os.path.dirname(__file__)), "static", "templates"),
    #                                                     missing parens ---------^
)

在Python中,当你得到一个没有立即理解的语法错误时,请检查前面的行以确保你的大括号和圆括号正确平衡。对于每个烤箱({[必须是匹配的结束)}]