diff --git a/django/forms/models.py b/django/forms/models.py
index 8084e16c8d..b4d29c3886 100644
a
|
b
|
class BaseModelFormSet(BaseFormSet, AltersData):
|
847 | 847 | # poke error messages into the right places and mark |
848 | 848 | # the form as invalid |
849 | 849 | errors.append(self.get_unique_error_message(unique_check)) |
850 | | form._errors[NON_FIELD_ERRORS] = self.error_class( |
851 | | [self.get_form_error()], |
852 | | renderer=self.renderer, |
853 | | ) |
| 850 | self.process_unique_error(form, unique_check, row_data) |
854 | 851 | # Remove the data from the cleaned_data dict since it |
855 | 852 | # was invalid. |
856 | 853 | for field in unique_check: |
… |
… |
class BaseModelFormSet(BaseFormSet, AltersData):
|
883 | 880 | # poke error messages into the right places and mark |
884 | 881 | # the form as invalid |
885 | 882 | errors.append(self.get_date_error_message(date_check)) |
886 | | form._errors[NON_FIELD_ERRORS] = self.error_class( |
887 | | [self.get_form_error()], |
888 | | renderer=self.renderer, |
889 | | ) |
| 883 | self.process_date_error(form, date_check, data) |
890 | 884 | # Remove the data from the cleaned_data dict since it |
891 | 885 | # was invalid. |
892 | 886 | del form.cleaned_data[field] |
… |
… |
class BaseModelFormSet(BaseFormSet, AltersData):
|
896 | 890 | if errors: |
897 | 891 | raise ValidationError(errors) |
898 | 892 | |
| 893 | def process_unique_error(self, form, unique_check, row_data): |
| 894 | form._errors[NON_FIELD_ERRORS] = self.error_class( |
| 895 | [self.get_form_error()], |
| 896 | renderer=self.renderer, |
| 897 | ) |
| 898 | |
| 899 | def process_date_error(self, form, date_check, data): |
| 900 | form._errors[NON_FIELD_ERRORS] = self.error_class( |
| 901 | [self.get_form_error()], |
| 902 | renderer=self.renderer, |
| 903 | ) |
| 904 | |
899 | 905 | def get_unique_error_message(self, unique_check): |
900 | 906 | if len(unique_check) == 1: |
901 | 907 | return gettext("Please correct the duplicate data for %(field)s.") % { |