Code

Ticket #18361: form_widget_iteration.diff

File form_widget_iteration.diff, 494 bytes (added by kmichel_wgs, 2 years ago)
Line 
1diff --git a/django/forms/forms.py b/django/forms/forms.py
2index 09663d1..2957063 100644
3--- a/django/forms/forms.py
4+++ b/django/forms/forms.py
5@@ -424,7 +424,10 @@ class BoundField(StrAndUnicode):
6         return len(list(self.__iter__()))
7 
8     def __getitem__(self, idx):
9-        return list(self.__iter__())[idx]
10+        if isinstance(idx, int):
11+            return list(self.__iter__())[idx]
12+        else:
13+            raise AttributeError(idx)
14 
15     def _errors(self):
16         """