mirror of
https://github.com/django/django.git
synced 2025-10-28 08:06:09 +00:00
Fixed #20819 -- Return 404 instead of 500 error when `staticfiles` view is used in production.
This commit is contained in:
@@ -11,7 +11,6 @@ except ImportError: # Python 2
|
||||
from urllib import unquote
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.http import Http404
|
||||
from django.views import static
|
||||
|
||||
@@ -31,9 +30,7 @@ def serve(request, path, insecure=False, **kwargs):
|
||||
It uses the django.views.static view to serve the found files.
|
||||
"""
|
||||
if not settings.DEBUG and not insecure:
|
||||
raise ImproperlyConfigured("The staticfiles view can only be used in "
|
||||
"debug mode or if the --insecure "
|
||||
"option of 'runserver' is used")
|
||||
raise Http404
|
||||
normalized_path = posixpath.normpath(unquote(path)).lstrip('/')
|
||||
absolute_path = finders.find(normalized_path)
|
||||
if not absolute_path:
|
||||
|
||||
Reference in New Issue
Block a user