summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/conf/urls/static.py5
-rw-r--r--docs/howto/static-files.txt6
2 files changed, 8 insertions, 3 deletions
diff --git a/django/conf/urls/static.py b/django/conf/urls/static.py
index ff1942f990..8be564ec7a 100644
--- a/django/conf/urls/static.py
+++ b/django/conf/urls/static.py
@@ -15,12 +15,11 @@ def static(prefix, view='django.views.static.serve', **kwargs):
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
"""
- if not settings.DEBUG:
+ # No-op if not in debug mode or an non-local prefix
+ if not settings.DEBUG or (prefix and '://' in prefix):
return []
elif not prefix:
raise ImproperlyConfigured("Empty static prefix not permitted")
- elif '://' in prefix:
- raise ImproperlyConfigured("URL '%s' not allowed as static prefix" % prefix)
return patterns('',
url(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
)
diff --git a/docs/howto/static-files.txt b/docs/howto/static-files.txt
index 2787c1cac8..77e07141e3 100644
--- a/docs/howto/static-files.txt
+++ b/docs/howto/static-files.txt
@@ -297,6 +297,12 @@ development::
# ... the rest of your URLconf goes here ...
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+.. note::
+
+ The helper function will only be operational in debug mode and if
+ the given prefix is local (e.g. ``/static/``) and not a URL (e.g.
+ ``http://static.example.com/``).
+
.. _staticfiles-production:
Serving static files in production