Fixed #28593 -- Added a simplified URL routing syntax per DEP 0201.

Thanks Aymeric Augustin for shepherding the DEP and patch review.
Thanks Marten Kenbeek and Tim Graham for contributing to the code.
Thanks Tom Christie, Shai Berger, and Tim Graham for the docs.
This commit is contained in:
Sjoerd Job Postmus 2016-10-20 19:29:04 +02:00 committed by Tim Graham
parent c4c128d67c
commit df41b5a05d
77 changed files with 1663 additions and 1105 deletions

View file

@ -1115,11 +1115,11 @@ hard-code URLs in your templates::
{% url 'some-url-name' v1 v2 %}
The first argument is a :func:`~django.conf.urls.url` ``name``. It can be a
quoted literal or any other context variable. Additional arguments are optional
and should be space-separated values that will be used as arguments in the URL.
The example above shows passing positional arguments. Alternatively you may
use keyword syntax::
The first argument is a :ref:`URL pattern name <naming-url-patterns>`. It can
be a quoted literal or any other context variable. Additional arguments are
optional and should be space-separated values that will be used as arguments in
the URL. The example above shows passing positional arguments. Alternatively
you may use keyword syntax::
{% url 'some-url-name' arg1=v1 arg2=v2 %}
@ -1132,14 +1132,14 @@ takes a client ID (here, ``client()`` is a method inside the views file
.. code-block:: python
('^client/([0-9]+)/$', app_views.client, name='app-views-client')
path('client/<int:id>/', app_views.client, name='app-views-client')
If this app's URLconf is included into the project's URLconf under a path
such as this:
.. code-block:: python
('^clients/', include('project_name.app_name.urls'))
path('clients/', include('project_name.app_name.urls'))
...then, in a template, you can create a link to this view like this::
@ -1179,8 +1179,8 @@ by the context as to the current application.
.. warning::
Don't forget to put quotes around the :func:`~django.conf.urls.url`
``name``, otherwise the value will be interpreted as a context variable!
Don't forget to put quotes around the URL pattern ``name``, otherwise the
value will be interpreted as a context variable!
.. templatetag:: verbatim