summaryrefslogtreecommitdiff
path: root/django/forms/formsets.py
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2021-12-11 20:17:29 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-12-21 12:06:05 +0100
commite95e6425ac354b8fb0c24580b740dbdc2ea72bd6 (patch)
treeabdadc46924748086d6788364f747abb76551029 /django/forms/formsets.py
parent61b332499d28afe1c7d413411166ad405663e750 (diff)
Refs #24121 -- Added __repr__() to BaseFormSet.
Diffstat (limited to 'django/forms/formsets.py')
-rw-r--r--django/forms/formsets.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py
index aca518b4d2..75b0646512 100644
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -103,6 +103,22 @@ class BaseFormSet(RenderableFormMixin):
"""
return True
+ def __repr__(self):
+ if self._errors is None:
+ is_valid = 'Unknown'
+ else:
+ is_valid = (
+ self.is_bound and
+ not self._non_form_errors and
+ not any(form_errors for form_errors in self._errors)
+ )
+ return '<%s: bound=%s valid=%s total_forms=%s>' % (
+ self.__class__.__qualname__,
+ self.is_bound,
+ is_valid,
+ self.total_form_count(),
+ )
+
@cached_property
def management_form(self):
"""Return the ManagementForm instance for this FormSet."""