mirror of
https://github.com/django/django.git
synced 2025-10-25 22:56:12 +00:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user