Question

I'm absolutely brand new to Python/Django/coding so I know there's probably something super simple that I'm missing. Any help in sorting this out would be awesome. Thanks in advance.

When I run python manage.py collectstatic I get in Terminal:

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

In my settings.py file I have this at line 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',
)

Here's the rest of the file (minus db info and such):

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',
)
Was it helpful?

Solution

You are missing a parenthesis on the previous lines:

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

I count 4 opening parens, but only 3 closing; you are not closing the os.path.join() call:

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

In Python, when you get a Syntax Error that doesn't immediately make sense, check the preceding lines to make sure you have your braces and parentheses properly balanced. For every ovening (, { or [ there must be a matching closing ), } or ].

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top