summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2009-12-13 17:46:52 +0000
committerKaren Tracey <kmtracey@gmail.com>2009-12-13 17:46:52 +0000
commit125403ca972d4964691ee206acc6c28c0b3eab9d (patch)
tree948c0f1a54423ec91b90c73e81047482d70a015f /django
parent6a7db77e957ab00445982484e553a65dc691604a (diff)
Fixed #12215: Added len to ModelChoiceIterator. Thanks Alex and Tobias.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11850 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/forms/models.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 61ff8e4dcc..3f7621e5e7 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -910,6 +910,9 @@ class ModelChoiceIterator(object):
for obj in self.queryset.all():
yield self.choice(obj)
+ def __len__(self):
+ return len(self.queryset)
+
def choice(self, obj):
if self.field.to_field_name:
key = obj.serializable_value(self.field.to_field_name)