diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-02-14 23:45:41 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-02-14 23:45:41 +0000 |
| commit | 4bb2db0caec69bfa5903fbc81d2635cc17922c46 (patch) | |
| tree | a0a441c0a312933dca3dbc2aae128ec3ff3a51af | |
| parent | 64a0a33c33079fa8ea79f1935d2a56281427e0f0 (diff) | |
Modified the staticfiles serve view to return a 404 early in the stack.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15539 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/staticfiles/views.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/django/contrib/staticfiles/views.py b/django/contrib/staticfiles/views.py index 123a01a557..5df1a3eced 100644 --- a/django/contrib/staticfiles/views.py +++ b/django/contrib/staticfiles/views.py @@ -25,7 +25,7 @@ def serve(request, path, document_root=None, insecure=False, **kwargs): in your URLconf. - It automatically falls back to django.views.static + 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 " @@ -33,6 +33,7 @@ def serve(request, path, document_root=None, insecure=False, **kwargs): "option of 'runserver' is used") normalized_path = posixpath.normpath(urllib.unquote(path)).lstrip('/') absolute_path = finders.find(normalized_path) - if absolute_path: - document_root, path = os.path.split(absolute_path) + if not absolute_path: + 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) |
