Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Jannis Leidel authored March 15, 2011
5  django/conf/urls/static.py
@@ -15,12 +15,11 @@ def static(prefix, view='django.views.static.serve', **kwargs):
15 15
     ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
16 16
 
17 17
     """
18  
-    if not settings.DEBUG:
  18
+    # No-op if not in debug mode or an non-local prefix
  19
+    if not settings.DEBUG or (prefix and '://' in prefix):
19 20
         return []
20 21
     elif not prefix:
21 22
         raise ImproperlyConfigured("Empty static prefix not permitted")
22  
-    elif '://' in prefix:
23  
-        raise ImproperlyConfigured("URL '%s' not allowed as static prefix" % prefix)
24 23
     return patterns('',
25 24
         url(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
26 25
     )
6  docs/howto/static-files.txt
@@ -297,6 +297,12 @@ development::
297 297
         # ... the rest of your URLconf goes here ...
298 298
     ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
299 299
 
  300
+.. note::
  301
+
  302
+    The helper function will only be operational in debug mode and if
  303
+    the given prefix is local (e.g. ``/static/``) and not a URL (e.g.
  304
+    ``http://static.example.com/``).
  305
+
300 306
 .. _staticfiles-production:
301 307
 
302 308
 Serving static files in production

0 notes on commit ad4118b

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