2

我对 Python/Django/coding 完全陌生,所以我知道我可能缺少一些超级简单的东西。解决这个问题的任何帮助都会很棒。提前致谢。

当我运行时,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',
)

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

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',
)
4

1 回答 1

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 中,当您遇到无法立即理解的语法错误时,请检查前面的行以确保您的大括号和括号正确平衡。每次烘烤({必须[有一个匹配的结束,或。)}]

于 2013-07-29T16:49:20.490 回答