diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2013-06-15 22:34:25 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-06-16 15:49:30 -0400 |
| commit | 1b7634a0d0e21faba71a27ae7951d7cb7aec0e49 (patch) | |
| tree | 2f8bfcd40db77f76410364f66be89ee584947c42 /django | |
| parent | aa22cbd51aa6cb35fc658dd704948a18b27d1981 (diff) | |
Fixed #20464 -- Added a `total_error_count` method on formsets.
Thanks to frog32 for the report and to Tim Graham for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/templates/admin/change_list.html | 2 | ||||
| -rw-r--r-- | django/forms/formsets.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/django/contrib/admin/templates/admin/change_list.html b/django/contrib/admin/templates/admin/change_list.html index 5d1a6b2714..200b4cd74d 100644 --- a/django/contrib/admin/templates/admin/change_list.html +++ b/django/contrib/admin/templates/admin/change_list.html @@ -64,7 +64,7 @@ {% endblock %} {% if cl.formset.errors %} <p class="errornote"> - {% if cl.formset.errors|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %} + {% if cl.formset.total_error_count == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %} </p> {{ cl.formset.non_form_errors }} {% endif %} diff --git a/django/forms/formsets.py b/django/forms/formsets.py index fd98c43405..79e1c2298a 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -263,6 +263,13 @@ class BaseFormSet(object): self.full_clean() return self._errors + def total_error_count(self): + """ + Returns the number of errors across all forms in the formset. + """ + return len(self.non_form_errors()) +\ + sum(len(form_errors) for form_errors in self.errors) + def _should_delete_form(self, form): """ Returns whether or not the form was marked for deletion. |
