Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@jezdez jezdez authored
View
16 django/contrib/staticfiles/storage.py
@@ -30,17 +30,17 @@ def __init__(self, location=None, base_url=None, *args, **kwargs):
location = settings.STATIC_ROOT
if base_url is None:
base_url = settings.STATIC_URL
- if not location:
- raise ImproperlyConfigured("You're using the staticfiles app "
- "without having set the STATIC_ROOT setting.")
- # check for None since we might use a root URL (``/``)
- if base_url is None:
- raise ImproperlyConfigured("You're using the staticfiles app "
- "without having set the STATIC_URL setting.")
- check_settings()
+ check_settings(base_url)
super(StaticFilesStorage, self).__init__(location, base_url,
*args, **kwargs)
+ def path(self, name):
+ if not self.location:
+ raise ImproperlyConfigured("You're using the staticfiles app "
+ "without having set the STATIC_ROOT "
+ "setting to a filesystem path.")
+ return super(StaticFilesStorage, self).path(name)
+
class CachedFilesMixin(object):
patterns = (
View
8 django/contrib/staticfiles/utils.py
@@ -37,16 +37,18 @@ def get_files(storage, ignore_patterns=None, location=''):
for fn in get_files(storage, ignore_patterns, dir):
yield fn
-def check_settings():
+def check_settings(base_url=None):
"""
Checks if the staticfiles settings have sane values.
"""
- if not settings.STATIC_URL:
+ if base_url is not None:
+ base_url = settings.STATIC_URL
+ if not base_url:
raise ImproperlyConfigured(
"You're using the staticfiles app "
"without having set the required STATIC_URL setting.")
- if settings.MEDIA_URL == settings.STATIC_URL:
+ if settings.MEDIA_URL == base_url:
raise ImproperlyConfigured("The MEDIA_URL and STATIC_URL "
"settings must have different values")
if ((settings.MEDIA_ROOT and settings.STATIC_ROOT) and
Please sign in to comment.
Something went wrong with that request. Please try again.