Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #15598 -- Updated static URL helper to be no-op on non-local pr…

…efixes. Thanks, traff.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15839 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ad4118be443266685cfc7ab2d59794e0692bc944 1 parent 5050e30
@jezdez jezdez authored
Showing with 8 additions and 3 deletions.
  1. +2 −3 django/conf/urls/static.py
  2. +6 −0 docs/howto/static-files.txt
View
5 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),
)
View
6 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
Please sign in to comment.
Something went wrong with that request. Please try again.