From 774a1012809bcce11e222e710212b6397eb5f1d8 Mon Sep 17 00:00:00 2001 From: Pk Patel <46714886+The5cheduler@users.noreply.github.com> Date: Fri, 26 Sep 2025 12:42:08 -0400 Subject: [PATCH] removing forms change only updating the messaging --- django/forms/forms.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/django/forms/forms.py b/django/forms/forms.py index 513a7edba2..6dbc2c6639 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -285,14 +285,10 @@ class BaseForm(RenderableFormMixin): error = ValidationError(error) if hasattr(error, "error_dict"): - if field is None: - error = error.error_dict - # Raise an error if the ValidationError contains more than one - # item or if the only item's key doesn't match the form field. - elif len(error.error_dict) != 1 or field not in error.error_dict: + if field is not None: raise TypeError( - "The argument `field` must be `None` when the `error` " - "argument contains errors for multiple fields." + "The argument `field` must be `None` when the `error` argument " + "is a ValidationError with an error_dict." ) else: error = error.error_dict @@ -316,7 +312,7 @@ class BaseForm(RenderableFormMixin): field_id=self[field].auto_id, ) self._errors[field].extend(error_list) - if hasattr(self, "cleaned_data") and field in self.cleaned_data: + if field in self.cleaned_data: del self.cleaned_data[field] def has_error(self, field, code=None):