summaryrefslogtreecommitdiff
path: root/django/forms/formsets.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/forms/formsets.py')
-rw-r--r--django/forms/formsets.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py
index d421770093..fd98c43405 100644
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -250,9 +250,9 @@ class BaseFormSet(object):
form -- i.e., from formset.clean(). Returns an empty ErrorList if there
are none.
"""
- if self._non_form_errors is not None:
- return self._non_form_errors
- return self.error_class()
+ if self._non_form_errors is None:
+ self.full_clean()
+ return self._non_form_errors
@property
def errors(self):
@@ -291,16 +291,20 @@ class BaseFormSet(object):
def full_clean(self):
"""
- Cleans all of self.data and populates self._errors.
+ Cleans all of self.data and populates self._errors and
+ self._non_form_errors.
"""
self._errors = []
+ self._non_form_errors = self.error_class()
+
if not self.is_bound: # Stop further processing.
return
for i in range(0, self.total_form_count()):
form = self.forms[i]
self._errors.append(form.errors)
try:
- if (self.validate_max and self.total_form_count() > self.max_num) or \
+ if (self.validate_max and
+ self.total_form_count() - len(self.deleted_forms) > self.max_num) or \
self.management_form.cleaned_data[TOTAL_FORM_COUNT] > self.absolute_max:
raise ValidationError(ungettext(
"Please submit %d or fewer forms.",