Forums

django admin gives servererror; collectstatic fails

django admin fails with server error (500). While debugging this, I want to run collectstatic, but that also fails:

$ python ./manage.py collectstatic

You have requested to collect static files at the destination location as specified in your settings.
This will overwrite existing files! Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes Traceback (most recent call last):

File "./manage.py", line 22, in <module>

execute_from_command_line(sys.argv)   File "/home/jacopsd/.virtualenvs/django_swingit/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line

utility.execute()   File "/home/jacopsd/.virtualenvs/django_swingit/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)   File "/home/jacopsd/.virtualenvs/django_swingit/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv

self.execute(*args, **cmd_options)   File "/home/jacopsd/.virtualenvs/django_swingit/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute

output = self.handle(*args, **options)   File "/home/jacopsd/.virtualenvs/django_swingit/local/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 193, in handle

collected = self.collect()   File "/home/jacopsd/.virtualenvs/django_swingit/local/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect

for finder in get_finders():   File "/home/jacopsd/.virtualenvs/django_swingit/local/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 264, in get_finders

yield get_finder(finder_path)   File "/home/jacopsd/.virtualenvs/django_swingit/local/lib/python2.7/site-packages/django/utils/lru_cache.py", line 100, in wrapper

result = user_function(*args, **kwds)   File "/home/jacopsd/.virtualenvs/django_swingit/local/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 277, in get_finder

return Finder()   File "/home/jacopsd/.virtualenvs/django_swingit/local/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 64, in __init__

if settings.STATIC_ROOT and os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(root):   File "/home/jacopsd/.virtualenvs/django_swingit/lib/python2.7/posixpath.py", line 367, in abspath

if not isabs(path):   File "/home/jacopsd/.virtualenvs/django_swingit/lib/python2.7/posixpath.py", line 61, in isabs
return s.startswith('/') AttributeError: 'tuple' object has no attribute 'startswith'

$

Additional info: My STATIC_ROOT is set in my settings.py file to an empty directory in my home directory. DJANGO_SETTINGS_MODULE is pointing to this settings file.

[edit by admin: formatting]

Hmm. That would suggest that you've set STATIC_ROOT to a tuple rather than to a string. Could you check the line where you specify it? If it looks OK to you, can I take a look at your code? We can see it from our side, but we always ask permission first.

Dear support

Thank you for your help. This is solved now.

Reason was that after the STATIC_ROOT path, there was a comma ',' which indeed made it a tuple. I didn't notice this before since there was another settings file with the same name in another directory which I was looking at and editing. But this settings file was not in use....

So after removing that comma things work fine.

Great! Thanks for confirming.