summaryrefslogtreecommitdiff
path: root/django/forms/formsets.py
diff options
context:
space:
mode:
authorWindson yang <wiwindson@outlook.com>2017-07-25 06:55:41 +0800
committerTim Graham <timograham@gmail.com>2017-07-24 18:55:41 -0400
commitf32d24652b920135eb6a0f3de74599f03e181731 (patch)
tree5bf51d72c1dcd4b6c8ca788fa94f790f951425cd /django/forms/formsets.py
parent28a02259cb938f35607c7a0aa3688a163871b57f (diff)
Fixed #28321 -- Prevented FormSet.full_clean() from adding errors from deleted forms.
Diffstat (limited to 'django/forms/formsets.py')
-rw-r--r--django/forms/formsets.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py
index 1c55d5f6df..7332e4b2f4 100644
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -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 \