Skip to content

Commit

Permalink
Fixed #15765 -- Stopped showing an odd error message when using the s…
Browse files Browse the repository at this point in the history
…taticfiles 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
  • Loading branch information
jezdez committed Jul 4, 2011
1 parent 87eb3a2 commit a373396
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions django/contrib/staticfiles/handlers.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def _should_handle(self, path):
* the host is provided as part of the base_url * the host is provided as part of the base_url
* the request's path isn't under the media path (or equal) * the request's path isn't under the media path (or equal)
""" """
return (self.base_url[2] != path and return path.startswith(self.base_url[2]) and not self.base_url[1]
path.startswith(self.base_url[2]) and not self.base_url[1])


def file_path(self, url): def file_path(self, url):
""" """
Expand Down
2 changes: 2 additions & 0 deletions django/contrib/staticfiles/views.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def serve(request, path, document_root=None, insecure=False, **kwargs):
normalized_path = posixpath.normpath(urllib.unquote(path)).lstrip('/') normalized_path = posixpath.normpath(urllib.unquote(path)).lstrip('/')
absolute_path = finders.find(normalized_path) absolute_path = finders.find(normalized_path)
if not absolute_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) raise Http404("'%s' could not be found" % path)
document_root, path = os.path.split(absolute_path) document_root, path = os.path.split(absolute_path)
return static.serve(request, path, document_root=document_root, **kwargs) return static.serve(request, path, document_root=document_root, **kwargs)

0 comments on commit a373396

Please sign in to comment.