diff -r aa90ee8d27e7 django/forms/formsets.py
a
|
b
|
|
254 | 254 | # We loop over every form.errors here rather than short circuiting on the |
255 | 255 | # first failure to make sure validation gets triggered for every form. |
256 | 256 | forms_valid = True |
| 257 | err = self.errors |
257 | 258 | for i in range(0, self.total_form_count()): |
258 | 259 | form = self.forms[i] |
259 | 260 | if self.can_delete: |
diff -r aa90ee8d27e7 tests/regressiontests/forms/formsets.py
a
|
b
|
|
1 | 1 | # -*- coding: utf-8 -*- |
| 2 | from django.test.testcases import TestCase |
2 | 3 | tests = """ |
3 | 4 | # Basic FormSet creation and usage ############################################ |
4 | 5 | |
… |
… |
|
722 | 723 | <ul class="errorlist"><li>You may only specify a drink once.</li></ul> |
723 | 724 | |
724 | 725 | """ |
| 726 | |
| 727 | from django import forms |
| 728 | from django.forms.formsets import BaseFormSet, formset_factory |
| 729 | |
| 730 | class EmptyFsetWontValidate(BaseFormSet): |
| 731 | def clean(self): |
| 732 | raise forms.ValidationError, "Clean method called" |
| 733 | |
| 734 | class SimpleForm(forms.Form): |
| 735 | name = forms.CharField() |
| 736 | |
| 737 | |
| 738 | class TestEmptyFormSet(TestCase): |
| 739 | def test_empty_formset_is_valid(self): |
| 740 | EmptyFsetWontValidateFormset = formset_factory(SimpleForm, extra=0, formset=EmptyFsetWontValidate) |
| 741 | formset = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'0'},prefix="form") |
| 742 | formset2 = EmptyFsetWontValidateFormset(data={'form-INITIAL_FORMS':'0', 'form-TOTAL_FORMS':'1', 'form-0-name':'bah' },prefix="form") |
| 743 | |
| 744 | self.assertFalse(formset.is_valid()) |
| 745 | self.assertFalse(formset2.is_valid()) |
diff -r aa90ee8d27e7 tests/regressiontests/forms/tests.py
a
|
b
|
|
40 | 40 | from fields import FieldsTests |
41 | 41 | from validators import TestFieldWithValidators |
42 | 42 | from widgets import WidgetTests |
| 43 | from formsets import TestEmptyFormSet |
43 | 44 | |
44 | 45 | from input_formats import * |
45 | 46 | |