# urls.py
site_media = os.path.join(os.path.dirname(__file__), 'site_media'
)
urlpatterns = patterns('',
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': site_media}),
)
I have problems to understand the meaning of the expression used in above statement.
'^site_media/(?P<path>.*)$'
What does it really mean?
Thank you
// ========== Updated based on comments ==============
Reference: Name Groups.
In Python regular expressions, the syntax for named regular-expression
groups is (?P<name>pattern), where name is the name of the group and
pattern is some pattern to match.
Comparison:
Method 1>
(r'^articles/(?P<year>\d{4})/(?P<month>\d{2})/$', 'news.views.month_archive'),
A request to /articles/2005/03/ would call the function
news.views.month_archive(request, year='2005', month='03'),
Method 2>
(r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'),
A request to /articles/2005/03/ would call the function
news.views.month_archive(request, '2005', '03').
urls are pretty well explained in the docs