Ticket #22961: staticfileshandler404.diff

File staticfileshandler404.diff, 1.2 KB (added by Wil Tan, 10 years ago)
  • django/contrib/staticfiles/handlers.py

    diff --git a/django/contrib/staticfiles/handlers.py b/django/contrib/staticfiles/handlers.py
    index bb54db6b..f3939a7f 100644
    a b  
    11from django.conf import settings
     2from django.core import urlresolvers
    23from django.core.handlers.wsgi import get_path_info, WSGIHandler
    34from django.utils.six.moves.urllib.parse import urlparse
    45from django.utils.six.moves.urllib.request import url2pathname
    class StaticFilesHandler(WSGIHandler):  
    5354                if settings.DEBUG:
    5455                    from django.views import debug
    5556                    return debug.technical_404_response(request, e)
    56         return super(StaticFilesHandler, self).get_response(request)
     57                else:
     58                    urlconf = settings.ROOT_URLCONF
     59                    urlresolvers.set_urlconf(urlconf)
     60                    resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
     61                    return self.get_exception_response(request, resolver, 404)
     62        else:
     63            return super(StaticFilesHandler, self).get_response(request)
    5764
    5865    def __call__(self, environ, start_response):
    5966        if not self._should_handle(get_path_info(environ)):
Back to Top