summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-08-15 15:39:22 -0400
committerGitHub <noreply@github.com>2016-08-15 15:39:22 -0400
commit937d752d3deabebe60dfbe9ff9823772730f336a (patch)
treee9eab6551a8d0a3fd3eceb8df2243e399620bddf /django
parent21aec54296708ae29a06d9a5b97ba665bed44394 (diff)
Fixed #27058 -- Reallowed the {% for %} tag to unpack any iterable.
Thanks Sergei Maertens for the report and patch.
Diffstat (limited to 'django')
-rw-r--r--django/template/defaulttags.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 624f07da7b..ce2265fde1 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(