URLs, like the collaterals, tightly link the various parts of Django's large framework into a single population, so it's a good idea to understand that Django starts from a URL.
The relationship between the general view template URL is not discussed here, and the following is a sample of the passing of the parameters in the URL.
1. Simple number of parameters to call
URL (R ' ^articles/(\d{4})/(\d{2})/$ ',' news.views.month_archive '),
For the above URL, suppose to parse with/articles/2005/03/. Finally, the view is resolved to the
news.views.month_archive (Request, ' 2005 ', ' a ') .
2. Call with named number of parameters
The above is simple, but do not have the name after the look is always confusing, not a good programming habit, first introduce the rules of the next number of names
(? P<name>pattern)
Same or the same logical example as before
URL (R ' ^articles/(? P<YEAR>\D{4})/(?
P<MONTH>\D{2})/$ ',' news.views.month_archive '),
Samewith/articles/2005/03/to parse, and finally resolves to
News.views.month_archive (request,year= ' 2005 ', month= ' 03 ')
It's a little clearer than it was before.
3. For URLs in template mappings
For the sample in 1:
{%url ' path.to.some_view 'v1 v2%}
For the sample in 2:
{%url ' path.to.some_view 'arg1=v1 arg2=v2 %}
Django URL with a number of parameters