mirror of
https://github.com/django/django.git
synced 2025-08-17 17:20:38 +00:00
[1.7.x] Fixed #23114 -- Clarified documentation of template lookups.
Thanks to gmunumel and Tom Dalton for their help on the patch.
Backport of 62c74abbb0
from master.
This commit is contained in:
parent
394053ce60
commit
13d44f54a2
1 changed files with 8 additions and 6 deletions
|
@ -95,13 +95,15 @@ Use a dot (``.``) to access attributes of a variable.
|
||||||
following lookups, in this order:
|
following lookups, in this order:
|
||||||
|
|
||||||
* Dictionary lookup
|
* Dictionary lookup
|
||||||
* Attribute lookup
|
* Attribute or method lookup
|
||||||
* Method call
|
* Numeric index lookup
|
||||||
* List-index lookup
|
|
||||||
|
|
||||||
This can cause some unexpected behavior with objects that override
|
If the resulting value is callable, it is called with no arguments. The
|
||||||
dictionary lookup. For example, consider the following code snippet that
|
result of the call becomes the template value.
|
||||||
attempts to loop over a ``collections.defaultdict``::
|
|
||||||
|
This lookup order can cause some unexpected behavior with objects that
|
||||||
|
override dictionary lookup. For example, consider the following code snippet
|
||||||
|
that attempts to loop over a ``collections.defaultdict``::
|
||||||
|
|
||||||
{% for k, v in defaultdict.iteritems %}
|
{% for k, v in defaultdict.iteritems %}
|
||||||
Do something with k and v here...
|
Do something with k and v here...
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue