From 6b730e1e92eb85beb3d3f7401ee5dce50895d758 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Tue, 20 Jun 2006 03:58:16 +0000 Subject: [PATCH] Fixed #2102 -- Template system 'for' loops now support generators. Thanks, dbm-django@mclachlan.com.au git-svn-id: http://code.djangoproject.com/svn/django/trunk@3165 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/template/defaulttags.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py index 8b52b70cda..88cb5f68be 100644 --- a/django/template/defaulttags.py +++ b/django/template/defaulttags.py @@ -88,6 +88,8 @@ class ForNode(Node): values = [] if values is None: values = [] + if not hasattr(values, '__len__'): + values = list(values) len_values = len(values) if self.reversed: # From http://www.python.org/doc/current/tut/node11.html