Loading django/forms/boundfield.py +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ class BoundField(object): def __getitem__(self, idx): # Prevent unnecessary reevaluation when accessing BoundField's attrs # from templates. if not isinstance(idx, six.integer_types): if not isinstance(idx, six.integer_types + (slice,)): raise TypeError return list(self.__iter__())[idx] Loading docs/releases/1.8.10.txt +2 −0 Original line number Diff line number Diff line Loading @@ -24,3 +24,5 @@ Bugfixes * Reallowed dashes in top-level domain names of URLs checked by ``URLValidator`` to fix a regression in Django 1.8 (:ticket:`26204`). * Fixed ``BoundField`` to reallow slices of subwidgets (:ticket:`26267`). docs/releases/1.9.3.txt +2 −0 Original line number Diff line number Diff line Loading @@ -40,3 +40,5 @@ Bugfixes * Fixed some crashing deprecation shims in ``SimpleTemplateResponse`` that regressed in Django 1.9 (:ticket:`26253`). * Fixed ``BoundField`` to reallow slices of subwidgets (:ticket:`26267`). docs/spelling_wordlist +1 −0 Original line number Diff line number Diff line Loading @@ -632,6 +632,7 @@ quoteless Radziej rc readded reallow reallowed rebase rebased Loading tests/forms_tests/tests/test_forms.py +14 −0 Original line number Diff line number Diff line Loading @@ -661,6 +661,20 @@ class FormsTestCase(SimpleTestCase): f = BeatleForm(auto_id=False) self.assertHTMLEqual('\n'.join(str(bf) for bf in f['name']), '<input type="text" name="name" />') def test_boundfield_slice(self): class BeatleForm(Form): name = ChoiceField( choices=[('john', 'John'), ('paul', 'Paul'), ('george', 'George'), ('ringo', 'Ringo')], widget=RadioSelect, ) f = BeatleForm() bf = f['name'] self.assertEqual( [str(item) for item in bf[1:]], [str(bf[1]), str(bf[2]), str(bf[3])], ) def test_forms_with_multiple_choice(self): # MultipleChoiceField is a special case, as its data is required to be a list: class SongForm(Form): Loading Loading
django/forms/boundfield.py +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ class BoundField(object): def __getitem__(self, idx): # Prevent unnecessary reevaluation when accessing BoundField's attrs # from templates. if not isinstance(idx, six.integer_types): if not isinstance(idx, six.integer_types + (slice,)): raise TypeError return list(self.__iter__())[idx] Loading
docs/releases/1.8.10.txt +2 −0 Original line number Diff line number Diff line Loading @@ -24,3 +24,5 @@ Bugfixes * Reallowed dashes in top-level domain names of URLs checked by ``URLValidator`` to fix a regression in Django 1.8 (:ticket:`26204`). * Fixed ``BoundField`` to reallow slices of subwidgets (:ticket:`26267`).
docs/releases/1.9.3.txt +2 −0 Original line number Diff line number Diff line Loading @@ -40,3 +40,5 @@ Bugfixes * Fixed some crashing deprecation shims in ``SimpleTemplateResponse`` that regressed in Django 1.9 (:ticket:`26253`). * Fixed ``BoundField`` to reallow slices of subwidgets (:ticket:`26267`).
docs/spelling_wordlist +1 −0 Original line number Diff line number Diff line Loading @@ -632,6 +632,7 @@ quoteless Radziej rc readded reallow reallowed rebase rebased Loading
tests/forms_tests/tests/test_forms.py +14 −0 Original line number Diff line number Diff line Loading @@ -661,6 +661,20 @@ class FormsTestCase(SimpleTestCase): f = BeatleForm(auto_id=False) self.assertHTMLEqual('\n'.join(str(bf) for bf in f['name']), '<input type="text" name="name" />') def test_boundfield_slice(self): class BeatleForm(Form): name = ChoiceField( choices=[('john', 'John'), ('paul', 'Paul'), ('george', 'George'), ('ringo', 'Ringo')], widget=RadioSelect, ) f = BeatleForm() bf = f['name'] self.assertEqual( [str(item) for item in bf[1:]], [str(bf[1]), str(bf[2]), str(bf[3])], ) def test_forms_with_multiple_choice(self): # MultipleChoiceField is a special case, as its data is required to be a list: class SongForm(Form): Loading