mirror of https://github.com/django/django.git
[1.9.x] Fixed #25574 -- Documented {{ dict.items }} shadowing in for template tag docs.
Backport of 32cd706971
from master
This commit is contained in:
parent
b5091a0475
commit
5a9e93e054
|
@ -327,6 +327,14 @@ would display the keys and values of the dictionary::
|
||||||
{{ key }}: {{ value }}
|
{{ key }}: {{ value }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
Keep in mind that for the dot operator, dictionary key lookup takes precedence
|
||||||
|
over method lookup. Therefore if the ``data`` dictionary contains a key named
|
||||||
|
``'items'``, ``data.items`` will return ``data['items']`` instead of
|
||||||
|
``data.items()``. Avoid adding keys that are named like dictionary methods if
|
||||||
|
you want to use those methods in a template (``items``, ``values``, ``keys``,
|
||||||
|
etc.). Read more about the lookup order of the dot operator in the
|
||||||
|
:ref:`documentation of template variables <template-variables>`.
|
||||||
|
|
||||||
The for loop sets a number of variables available within the loop:
|
The for loop sets a number of variables available within the loop:
|
||||||
|
|
||||||
========================== ===============================================
|
========================== ===============================================
|
||||||
|
|
|
@ -74,6 +74,8 @@ explained later in this document.
|
||||||
|
|
||||||
Oh, and one more thing: making humans edit XML is sadistic!
|
Oh, and one more thing: making humans edit XML is sadistic!
|
||||||
|
|
||||||
|
.. _template-variables:
|
||||||
|
|
||||||
Variables
|
Variables
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue