Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #16629 -- Relaxed check for STATIC_ROOT and STATIC_URL settings…

… slightly to only raise an exception if really needed.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16617 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2980f2ab9aabdea3a3b7ec343252889408690630 1 parent a13de6c
Jannis Leidel authored August 14, 2011
16  django/contrib/staticfiles/storage.py
@@ -30,17 +30,17 @@ def __init__(self, location=None, base_url=None, *args, **kwargs):
30 30
             location = settings.STATIC_ROOT
31 31
         if base_url is None:
32 32
             base_url = settings.STATIC_URL
33  
-        if not location:
34  
-            raise ImproperlyConfigured("You're using the staticfiles app "
35  
-                "without having set the STATIC_ROOT setting.")
36  
-        # check for None since we might use a root URL (``/``)
37  
-        if base_url is None:
38  
-            raise ImproperlyConfigured("You're using the staticfiles app "
39  
-                "without having set the STATIC_URL setting.")
40  
-        check_settings()
  33
+        check_settings(base_url)
41 34
         super(StaticFilesStorage, self).__init__(location, base_url,
42 35
                                                  *args, **kwargs)
43 36
 
  37
+    def path(self, name):
  38
+        if not self.location:
  39
+            raise ImproperlyConfigured("You're using the staticfiles app "
  40
+                                       "without having set the STATIC_ROOT "
  41
+                                       "setting to a filesystem path.")
  42
+        return super(StaticFilesStorage, self).path(name)
  43
+
44 44
 
45 45
 class CachedFilesMixin(object):
46 46
     patterns = (
8  django/contrib/staticfiles/utils.py
@@ -37,16 +37,18 @@ def get_files(storage, ignore_patterns=None, location=''):
37 37
         for fn in get_files(storage, ignore_patterns, dir):
38 38
             yield fn
39 39
 
40  
-def check_settings():
  40
+def check_settings(base_url=None):
41 41
     """
42 42
     Checks if the staticfiles settings have sane values.
43 43
 
44 44
     """
45  
-    if not settings.STATIC_URL:
  45
+    if base_url is not None:
  46
+        base_url = settings.STATIC_URL
  47
+    if not base_url:
46 48
         raise ImproperlyConfigured(
47 49
             "You're using the staticfiles app "
48 50
             "without having set the required STATIC_URL setting.")
49  
-    if settings.MEDIA_URL == settings.STATIC_URL:
  51
+    if settings.MEDIA_URL == base_url:
50 52
         raise ImproperlyConfigured("The MEDIA_URL and STATIC_URL "
51 53
                                    "settings must have different values")
52 54
     if ((settings.MEDIA_ROOT and settings.STATIC_ROOT) and

0 notes on commit 2980f2a

Please sign in to comment.
Something went wrong with that request. Please try again.