﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21947	Test server returns HTTP 500 on static files when STATIC_ROOT is None	madmox	nobody	"I observed that my development server returned HTTP 500 status codes for all static files since I changed a bit of configuration in my settings.py file:

settings.py file before modification:
{{{
...
if not DEBUG:
    STATIC_ROOT = os.environ.['DJANGO_STATIC_ROOT']
...
}}}


settings.py file after modification:
{{{
...
STATIC_ROOT = os.environ.get('DJANGO_STATIC_ROOT', None)
...
}}}

In my development environment, I don't set the 'DJANGO_STATIC_ROOT' environment variable since I only use the test server which is supposed to collect static files on the fly in the static dirs in the different apps. Here is the resulting exception and stack trace in the runserver window when I try to access a static file:

{{{
Traceback (most recent call last):
  File ""/usr/lib/python3.3/wsgiref/handlers.py"", line 137, in run
    self.result = application(self.environ, self.start_response)
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/site-packages/django/contrib/staticfiles/handlers.py"", line 68, in __call__
    return super(StaticFilesHandler, self).__call__(environ, start_response)
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/site-packages/django/core/handlers/wsgi.py"", line 206, in __call__
    response = self.get_response(request)
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/site-packages/django/contrib/staticfiles/handlers.py"", line 58, in get_response
    return self.serve(request)
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/site-packages/django/contrib/staticfiles/handlers.py"", line 51, in serve
    return serve(request, self.file_path(request.path), insecure=True)
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/site-packages/django/contrib/staticfiles/views.py"", line 35, in serve
    absolute_path = finders.find(normalized_path)
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/site-packages/django/contrib/staticfiles/finders.py"", line 238, in find
    for finder in get_finders():
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/site-packages/django/contrib/staticfiles/finders.py"", line 253, in get_finders
    yield get_finder(finder_path)
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/site-packages/django/utils/functional.py"", line 32, in wrapper
    result = func(*args)
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/site-packages/django/contrib/staticfiles/finders.py"", line 265, in _get_finder
    return Finder()
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/site-packages/django/contrib/staticfiles/finders.py"", line 60, in __init__
    if os.path.abspath(settings.STATIC_ROOT) == os.path.abspath(root):
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/posixpath.py"", line 379, in abspath
    if not isabs(path):
  File ""/home/madmox/.virtualenvs/django-dev/lib/python3.3/posixpath.py"", line 64, in isabs
    return s.startswith(sep)
AttributeError: 'NoneType' object has no attribute 'startswith'
[04/Feb/2014 03:35:03] ""GET /static/about/css/app.css HTTP/1.1"" 500 59
}}}

This is a little bit unexpected since the documentation states the default value for STATIC_ROOT is None."	Bug	closed	contrib.staticfiles	1.6	Normal	duplicate	STATIC_ROOT runserver test server		Unreviewed	0	0	0	0	0	0
