summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-12-02 00:43:36 +0000
committerJannis Leidel <jannis@leidel.info>2010-12-02 00:43:36 +0000
commit3d5bb27945e1fc0727309c3656b7727fca3eed28 (patch)
treecd0d19db9986533c9a72674b1542f4f360340085
parenta172ed00afb896fdf222b6a9db33995c1194b7af (diff)
Added an additional check for the availability of the STATIC_* settings to make sure upgrading a pre-1.3 project doesn't raise a misleading error. Thanks for the report, Florian Apolloner.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14767 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/staticfiles/handlers.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/contrib/staticfiles/handlers.py b/django/contrib/staticfiles/handlers.py
index 2b7276133f..ace19f4f09 100644
--- a/django/contrib/staticfiles/handlers.py
+++ b/django/contrib/staticfiles/handlers.py
@@ -2,6 +2,7 @@ import urllib
from urlparse import urlparse
from django.conf import settings
+from django.core.exceptions import ImproperlyConfigured
from django.core.handlers.wsgi import WSGIHandler
from django.contrib.staticfiles import utils
@@ -25,6 +26,10 @@ class StaticFilesHandler(WSGIHandler):
return settings.STATIC_ROOT
def get_base_url(self):
+ if not settings.STATIC_URL:
+ raise ImproperlyConfigured("You're using the staticfiles app "
+ "without having set the STATIC_URL setting. Set it to "
+ "URL that handles the files served from STATIC_ROOT.")
if settings.DEBUG:
utils.check_settings()
return settings.STATIC_URL
@@ -42,10 +47,6 @@ class StaticFilesHandler(WSGIHandler):
def file_path(self, url):
"""
Returns the relative path to the media file on disk for the given URL.
-
- The passed URL is assumed to begin with ``base_url``. If the
- resultant file path is outside the media directory, then a ValueError
- is raised.
"""
relative_url = url[len(self.base_url[2]):]
return urllib.url2pathname(relative_url)