Kaydet (Commit) a3733967 authored tarafından Jannis Leidel's avatar Jannis Leidel

Fixed #15765 -- Stopped showing an odd error message when using the staticfiles…

Fixed #15765 -- Stopped showing an odd error message when using the staticfiles enabled runserver management command and trying to serve files from STATIC_URL at the same time.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16503 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 87eb3a25
......@@ -35,8 +35,7 @@ class StaticFilesHandler(WSGIHandler):
* the host is provided as part of the base_url
* the request's path isn't under the media path (or equal)
"""
return (self.base_url[2] != path and
path.startswith(self.base_url[2]) and not self.base_url[1])
return path.startswith(self.base_url[2]) and not self.base_url[1]
def file_path(self, url):
"""
......
......@@ -34,6 +34,8 @@ def serve(request, path, document_root=None, insecure=False, **kwargs):
normalized_path = posixpath.normpath(urllib.unquote(path)).lstrip('/')
absolute_path = finders.find(normalized_path)
if not absolute_path:
if path.endswith('/') or path == '':
raise Http404("Directory indexes are not allowed here.")
raise Http404("'%s' could not be found" % path)
document_root, path = os.path.split(absolute_path)
return static.serve(request, path, document_root=document_root, **kwargs)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment