Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'tuple' object has no attribute 'startswith'

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',
)
like image 825
Chris K Avatar asked Jul 29 '13 18:07

Chris K


3 Answers

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.

like image 145
Andrey Nelubin Avatar answered Oct 31 '22 21:10

Andrey Nelubin


@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 :)

like image 4
Jitesh Nair Avatar answered Oct 31 '22 23:10

Jitesh Nair


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")
like image 3
abhimanyu gaur Avatar answered Oct 31 '22 22:10

abhimanyu gaur