summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2010-09-07 20:45:48 +0000
committerLuke Plant <L.Plant.98@cantab.net>2010-09-07 20:45:48 +0000
commit79d92067119569e95f2a0aa6827586d83ab88eda (patch)
tree0f61441f477db0a87dce3e69032915022e929ccc /django
parenta537235d7fff5f6c66e8d0276b8a0181e1adf9d9 (diff)
[1.2.X] Fixed #13414 - QuerySet API ref wrong sql equivalent in __year lookup example
Thanks to idle for report and patch Backport of [13690] from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13693 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/template/defaulttags.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 318ae5ffd2..d629a690c5 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -157,15 +157,22 @@ class ForNode(Node):
loop_dict['first'] = (i == 0)
loop_dict['last'] = (i == len_values - 1)
+ pop_context = False
if unpack:
# If there are multiple loop variables, unpack the item into
# them.
- context.update(dict(zip(self.loopvars, item)))
+ try:
+ unpacked_vars = dict(zip(self.loopvars, item))
+ except TypeError:
+ pass
+ else:
+ pop_context = True
+ context.update(unpacked_vars)
else:
context[self.loopvars[0]] = item
for node in self.nodelist_loop:
nodelist.append(node.render(context))
- if unpack:
+ if pop_context:
# The loop variables were pushed on to the context so pop them
# off again. This is necessary because the tag lets the length
# of loopvars differ to the length of each set of items and we