mirror of
https://github.com/django/django.git
synced 2025-07-23 05:05:17 +00:00
[1.10.x] Fixed #27001 -- Fixed a query count regression in ModelChoiceField with RadioSelect.
Backport of c5ebfda002
from master
This commit is contained in:
parent
a8b8ef114d
commit
86ae2b22ae
3 changed files with 16 additions and 2 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue