Completely new to coding, sorry for the simple questions. I'm getting this attribute error when running python manage.py collectstatic
. I'm editing settings.py
. I have Django 1.5.1 and Python 2.7.5. Any help is appreciated and thanks in advance (again).
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 61, in isabs
return s.startswith('/')
AttributeError: 'tuple' object has no attribute 'startswith'
Now, of course I've never messed with posixpath.py
.
here's the contents of settings.py
(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',
)
You do it wrong. You shouldn't turn your code in quotes. Watch here how it should be
It should be like:
STATICFILES_DIRS = (
os.path.join(os.path.dirname(__file__), "static")
)
Also it belongs to your MEDIA_ROOT
and STATIC_ROOT
settings.
@chris
STATIC_ROOT and MEDIA_ROOTS are absolute paths and they cannot be tuples so no ","(commas) is allowed, So mention the absolute path as "/your/static/file/absolute/path"
Hope this will help :)
STATIC_ROOT = os.path.join(BASE_DIR, "static_in_pro","static_root"),
Please Remove the comma at end of Static root
STATIC_ROOT = os.path.join(BASE_DIR, "static_in_pro","static_root")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With