diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-07-04 16:19:54 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-07-04 16:19:54 +0000 |
| commit | a3733967e89d38e42c2094d887aa985ffe5e9916 (patch) | |
| tree | 810325521eed5c51ebc1d0706756b97390820cd8 | |
| parent | 87eb3a25aa7cca071b0768ae94a7914952af9eb3 (diff) | |
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
| -rw-r--r-- | django/contrib/staticfiles/handlers.py | 3 | ||||
| -rw-r--r-- | django/contrib/staticfiles/views.py | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/django/contrib/staticfiles/handlers.py b/django/contrib/staticfiles/handlers.py index b51b7c8fd5..962b835fef 100644 --- a/django/contrib/staticfiles/handlers.py +++ b/django/contrib/staticfiles/handlers.py @@ -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): """ diff --git a/django/contrib/staticfiles/views.py b/django/contrib/staticfiles/views.py index 5df1a3eced..1a9c166ad7 100644 --- a/django/contrib/staticfiles/views.py +++ b/django/contrib/staticfiles/views.py @@ -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) |
