mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #26844 -- Made formset's validate_min validation ignore empty forms.
This commit is contained in:
parent
1e32e1cc95
commit
f5c6295797
2 changed files with 16 additions and 1 deletions
|
@ -377,6 +377,17 @@ class FormsFormsetTestCase(SimpleTestCase):
|
|||
self.assertFalse(formset.is_valid())
|
||||
self.assertEqual(formset.non_form_errors(), ['Please submit 3 or more forms.'])
|
||||
|
||||
def test_formset_validate_min_excludes_empty_forms(self):
|
||||
data = {
|
||||
'choices-TOTAL_FORMS': '2',
|
||||
'choices-INITIAL_FORMS': '0',
|
||||
}
|
||||
ChoiceFormSet = formset_factory(Choice, extra=2, min_num=1, validate_min=True, can_delete=True)
|
||||
formset = ChoiceFormSet(data, prefix='choices')
|
||||
self.assertFalse(formset.has_changed())
|
||||
self.assertFalse(formset.is_valid())
|
||||
self.assertEqual(formset.non_form_errors(), ['Please submit 1 or more forms.'])
|
||||
|
||||
def test_second_form_partially_filled_2(self):
|
||||
# And once again, if we try to partially complete a form, validation will fail.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue