Removed some discussion of deprecated {% url %} behavior.
This commit is contained in:
parent
5528e7da1a
commit
d06014db53
|
@ -1031,18 +1031,17 @@ url
|
||||||
^^^
|
^^^
|
||||||
|
|
||||||
Returns an absolute path reference (a URL without the domain name) matching a
|
Returns an absolute path reference (a URL without the domain name) matching a
|
||||||
given view function and optional parameters. Any special characters in the
|
given view and optional parameters. Any special characters in the resulting
|
||||||
resulting path will be encoded using :func:`~django.utils.encoding.iri_to_uri`.
|
path will be encoded using :func:`~django.utils.encoding.iri_to_uri`.
|
||||||
|
|
||||||
This is a way to output links without violating the DRY principle by having to
|
This is a way to output links without violating the DRY principle by having to
|
||||||
hard-code URLs in your templates::
|
hard-code URLs in your templates::
|
||||||
|
|
||||||
{% url 'some-url-name' v1 v2 %}
|
{% url 'some-url-name' v1 v2 %}
|
||||||
|
|
||||||
The first argument is a path to a view function in the format
|
The first argument is a :func:`~django.conf.urls.url` ``name``. It can be a
|
||||||
``package.package.module.function``. It can be a quoted literal or any other
|
quoted literal or any other context variable. Additional arguments are optional
|
||||||
context variable. Additional arguments are optional and
|
and should be space-separated values that will be used as arguments in the URL.
|
||||||
should be space-separated values that will be used as arguments in the URL.
|
|
||||||
The example above shows passing positional arguments. Alternatively you may
|
The example above shows passing positional arguments. Alternatively you may
|
||||||
use keyword syntax::
|
use keyword syntax::
|
||||||
|
|
||||||
|
@ -1057,7 +1056,7 @@ takes a client ID (here, ``client()`` is a method inside the views file
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
('^client/([0-9]+)/$', 'app_views.client', name='app-views-client')
|
('^client/([0-9]+)/$', app_views.client, name='app-views-client')
|
||||||
|
|
||||||
If this app's URLconf is included into the project's URLconf under a path
|
If this app's URLconf is included into the project's URLconf under a path
|
||||||
such as this:
|
such as this:
|
||||||
|
@ -1072,10 +1071,6 @@ such as this:
|
||||||
|
|
||||||
The template tag will output the string ``/clients/client/123/``.
|
The template tag will output the string ``/clients/client/123/``.
|
||||||
|
|
||||||
If you're using :ref:`named URL patterns <naming-url-patterns>`, you can
|
|
||||||
refer to the name of the pattern in the ``url`` tag instead of using the
|
|
||||||
path to the view.
|
|
||||||
|
|
||||||
Note that if the URL you're reversing doesn't exist, you'll get an
|
Note that if the URL you're reversing doesn't exist, you'll get an
|
||||||
:exc:`~django.core.urlresolvers.NoReverseMatch` exception raised, which will
|
:exc:`~django.core.urlresolvers.NoReverseMatch` exception raised, which will
|
||||||
cause your site to display an error page.
|
cause your site to display an error page.
|
||||||
|
@ -1108,15 +1103,15 @@ by the context as to the current application.
|
||||||
|
|
||||||
.. deprecated:: 1.8
|
.. deprecated:: 1.8
|
||||||
|
|
||||||
The dotted Python path syntax is deprecated and will be removed in
|
You can also pass a dotted Python path to a view function, but this syntax
|
||||||
Django 1.10::
|
is deprecated and will be removed in Django 1.10::
|
||||||
|
|
||||||
{% url 'path.to.some_view' v1 v2 %}
|
{% url 'path.to.some_view' v1 v2 %}
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
Don't forget to put quotes around the function path or pattern name,
|
Don't forget to put quotes around the :func:`~django.conf.urls.url`
|
||||||
otherwise the value will be interpreted as a context variable!
|
``name``, otherwise the value will be interpreted as a context variable!
|
||||||
|
|
||||||
.. templatetag:: verbatim
|
.. templatetag:: verbatim
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue