The URL is like a tendon that connects the various parts of the Django framework tightly into a single whole, so it's a good idea to understand that Django starts from the URL.
The relationship between the general view template URL is not covered here, and the following is a detailed example of the parameters passed in the URL.
1. Simple parameter invocation
URL (R ' ^articles/(\d{4})/(\d{2})/$ ',' news.views.month_archive '),
For the above URL, if you use /articles/2005/03/to parse, the end will be resolved to the view to
news.views.month_archive (Request, ' 2005 ', ' a ') .
2. Call with named arguments
The above is simple, but without the name of the argument is always confusing, not a good programming habit, first introduce the rules of the parameter name
(? P<name>pattern)
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 example in 1, use:
{%url ' path.to.some_view 'v1 v2%}
For the example in 2, use:
{%url ' path.to.some_view 'arg1=v1 arg2=v2 %}
Django URL with parameters