diff options
| author | Tim Graham <timograham@gmail.com> | 2016-08-15 15:39:22 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-15 15:40:34 -0400 |
| commit | 020ba4bf91aec9b13f415ace5cd538958ce3b608 (patch) | |
| tree | d60fd177fc754784915941184060a8d70d3c0a02 /django | |
| parent | 54771f6605147136ca954e2e3fc35ad804a89327 (diff) | |
[1.10.x] Fixed #27058 -- Reallowed the {% for %} tag to unpack any iterable.
Thanks Sergei Maertens for the report and patch.
Backport of 937d752d3deabebe60dfbe9ff9823772730f336a from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/template/defaulttags.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 8ab1f1dbdc..5f743caffd 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -189,10 +189,10 @@ class ForNode(Node): if unpack: # If there are multiple loop variables, unpack the item into # them. - if not isinstance(item, (list, tuple)): - len_item = 1 - else: + try: len_item = len(item) + except TypeError: # not an iterable + len_item = 1 # Check loop variable count before unpacking if num_loopvars != len_item: raise ValueError( |
