Hello site
[auf_framonde.git] / eggs / Django-1.4.5-py2.7.egg / django / conf / urls / static.py
CommitLineData
01b54c21
MN
1import re
2from django.conf import settings
3from django.conf.urls import patterns, url
4from django.core.exceptions import ImproperlyConfigured
5
6def static(prefix, view='django.views.static.serve', **kwargs):
7 """
8 Helper function to return a URL pattern for serving files in debug mode.
9
10 from django.conf import settings
11 from django.conf.urls.static import static
12
13 urlpatterns = patterns('',
14 # ... the rest of your URLconf goes here ...
15 ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
16
17 """
18 # No-op if not in debug mode or an non-local prefix
19 if not settings.DEBUG or (prefix and '://' in prefix):
20 return []
21 elif not prefix:
22 raise ImproperlyConfigured("Empty static prefix not permitted")
23 return patterns('',
24 url(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
25 )