1
0
mirror of https://github.com/django/django.git synced 2025-03-31 19:46:42 +00:00

Fixed #13116 -- Described scope of variables created by {% url ... as var %} syntax.

Thanks leif_p for the suggestion.
This commit is contained in:
Tim Graham 2014-01-17 14:50:47 -05:00
parent a67e327db5
commit 4a5aac47a6

View File

@ -1053,11 +1053,13 @@ cause your site to display an error page.
If you'd like to retrieve a URL without displaying it, you can use a slightly
different call::
{% url 'path.to.view' arg arg2 as the_url %}
<a href="{{ the_url }}">I'm linking to {{ the_url }}</a>
The scope of the variable created by the ``as var`` syntax is the
``{% block %}`` in which the ``{% url %}`` tag appears.
This ``{% url ... as var %}`` syntax will *not* cause an error if the view is
missing. In practice you'll use this to link to views that are optional::