Fixed #28321 -- Prevented FormSet.full_clean() from adding errors from deleted forms.
This commit is contained in:
parent
28a02259cb
commit
f32d24652b
|
@ -324,8 +324,12 @@ class BaseFormSet:
|
|||
# Empty forms are unchanged forms beyond those with initial data.
|
||||
if not form.has_changed() and i >= self.initial_form_count():
|
||||
empty_forms_count += 1
|
||||
|
||||
self._errors.append(form.errors)
|
||||
# Accessing errors calls full_clean() if necessary.
|
||||
# _should_delete_form() requires cleaned_data.
|
||||
form_errors = form.errors
|
||||
if self.can_delete and self._should_delete_form(form):
|
||||
continue
|
||||
self._errors.append(form_errors)
|
||||
try:
|
||||
if (self.validate_max and
|
||||
self.total_form_count() - len(self.deleted_forms) > self.max_num) or \
|
||||
|
|
|
@ -597,6 +597,7 @@ class FormsFormsetTestCase(SimpleTestCase):
|
|||
'form-MIN_NUM_FORMS': 0, 'form-MAX_NUM_FORMS': 1})
|
||||
|
||||
self.assertTrue(p.is_valid())
|
||||
self.assertEqual(p._errors, [])
|
||||
self.assertEqual(len(p.deleted_forms), 1)
|
||||
|
||||
def test_formsets_with_ordering(self):
|
||||
|
|
Loading…
Reference in New Issue