def __init__(self, location=None, base_url=None, *args, **kwargs): if location is None: location = settings.STATIC_ROOT if base_url is None: base_url = settings.STATIC_URL check_settings(base_url) super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
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
def __init__(self, location=None, base_url=None, static_root='', static_url=None, *args, **kwargs): if location is None: location = static_root if base_url is None: base_url = static_url check_settings(base_url) super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
def __init__(self, application, media_dir=None): self.application = application if media_dir: self.media_dir = media_dir else: self.media_dir = self.get_media_dir() self.media_url = urlparse(self.get_media_url()) if settings.DEBUG: utils.check_settings() super(StaticFilesHandler, self).__init__()
def __init__(self, location=None, base_url=None, *args, **kwargs): if location is None: 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 to a filesystem path.") check_settings(base_url) super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
def __init__(self, location=None, base_url=None, *args, **kwargs): if location is None: location = settings.STATIC_ROOT if base_url is None: base_url = settings.STATIC_URL check_settings(base_url) super().__init__(location, base_url, *args, **kwargs) # FileSystemStorage fallbacks to MEDIA_ROOT when location # is empty, so we restore the empty value. if not location: self.base_location = None self.location = None
def __init__(self, location=None, base_url=None, *args, **kwargs): if location is None: location = settings.STATIC_ROOT if base_url is None: base_url = settings.STATIC_URL check_settings(base_url) super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs) # FileSystemStorage fallbacks to MEDIA_ROOT when location # is empty, so we restore the empty value. if not location: self.base_location = None self.location = None
def base_url(self): if self._base_url is not None and not self._base_url.endswith('/'): self._base_url += '/' _url = self._value_or_setting(self._base_url, settings.STATIC_URL) _url = os.path.join(_url, utils.parse_tenant_config_path(self.relative_static_root)) if not _url.endswith("/"): _url += "/" check_settings(_url) return _url
def __init__(self, location=None, base_url=None, *args, **kwargs): if location is None: 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.") utils.check_settings() super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
def __init__(self, location=None, base_url=None, *args, **kwargs): if location is None: location = settings.STATICFILES_ROOT if base_url is None: base_url = settings.STATICFILES_URL if not location: raise ImproperlyConfigured("You're using the staticfiles app " "without having set the STATICFILES_ROOT setting. Set it to " "the absolute path of the directory that holds static media.") if not base_url: raise ImproperlyConfigured("You're using the staticfiles app " "without having set the STATICFILES_URL setting. Set it to " "URL that handles the files served from STATICFILES_ROOT.") if settings.DEBUG: utils.check_settings() super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
def __init__(self, location=None, base_url=None, *args, **kwargs): if location is None: 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. Set it to " "the absolute path of the directory that holds static files.") # 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. Set it to " "URL that handles the files served from STATIC_ROOT.") utils.check_settings() super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
def __init__(self, location=None, base_url=None, *args, **kwargs): if location is None: location = settings.STATICFILES_ROOT if base_url is None: base_url = settings.STATICFILES_URL if not location: raise ImproperlyConfigured( "You're using the staticfiles app " "without having set the STATICFILES_ROOT setting. Set it to " "the absolute path of the directory that holds static media.") if not base_url: raise ImproperlyConfigured( "You're using the staticfiles app " "without having set the STATICFILES_URL setting. Set it to " "URL that handles the files served from STATICFILES_ROOT.") if settings.DEBUG: utils.check_settings() super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
def __init__(self, location=None, base_url=None, *args, **kwargs): if location is None: 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. Set it to " "the absolute path of the directory that holds static files.") # 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. Set it to " "URL that handles the files served from STATIC_ROOT.") utils.check_settings() super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
def __init__(self, location=None, base_url=None, *args, **kwargs): try: relative_static_root = settings.MULTITENANT_RELATIVE_STATIC_ROOT except AttributeError: # MULTITENANT_RELATIVE_STATIC_ROOT is an optional setting, use the default value if none provided relative_static_root = "" relative_static_root = utils.parse_tenant_config_path( relative_static_root) if location is None: location = os.path.join(settings.STATIC_ROOT, relative_static_root) if base_url is None: base_url = os.path.join(settings.STATIC_URL, relative_static_root) if not base_url.endswith("/"): base_url += "/" check_settings(base_url) super(TenantStaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
from __future__ import unicode_literals
def test_media_url_in_static_url(self): msg = "runserver can't serve media if MEDIA_URL is within STATIC_URL." with self.assertRaisesMessage(ImproperlyConfigured, msg): check_settings() with self.settings(DEBUG=False): # Check disabled if DEBUG=False. check_settings()
from django.conf import settings
def get_base_url(self): utils.check_settings() # TODO: Don't hardcode this value return '/static/'
def get_base_url(self): utils.check_settings() return settings.STATIC_URL
def __init__(self, location=None, base_url=None, *args, **kwargs): if base_url is None: base_url = settings.STATIC_URL check_settings(base_url) self.base_url = base_url super(StaticFilesStorage, self).__init__(*args, **kwargs)