summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorAlex Hill <alex@hill.net.au>2016-08-03 11:12:06 +0800
committerTim Graham <timograham@gmail.com>2016-08-03 10:45:55 -0400
commitc5ebfda00226e3695cadbc13ea9ce4c5951d3ed0 (patch)
tree4142734f609dc73ce3820392a077b8a9642141ef /django/forms
parent4e64e3bb6e96a50b057bc1144fba3efdee7dfc10 (diff)
Fixed #27001 -- Fixed a query count regression in ModelChoiceField with RadioSelect.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/widgets.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 217f37b022..ec076398cc 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -693,8 +693,11 @@ class ChoiceFieldRenderer(object):
self.choices = choices
def __getitem__(self, idx):
- choice = list(self.choices)[idx] # Let the IndexError propagate
- return self.choice_input_class(self.name, self.value, self.attrs.copy(), choice, idx)
+ return list(self)[idx]
+
+ def __iter__(self):
+ for idx, choice in enumerate(self.choices):
+ yield self.choice_input_class(self.name, self.value, self.attrs.copy(), choice, idx)
def __str__(self):
return self.render()