removing forms change only updating the messaging

This commit is contained in:
Pk Patel 2025-09-26 12:42:08 -04:00 committed by GitHub
parent f73b3fbb0c
commit 774a101280
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -285,14 +285,10 @@ class BaseForm(RenderableFormMixin):
error = ValidationError(error) error = ValidationError(error)
if hasattr(error, "error_dict"): if hasattr(error, "error_dict"):
if field is None: if field is not 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:
raise TypeError( raise TypeError(
"The argument `field` must be `None` when the `error` " "The argument `field` must be `None` when the `error` argument "
"argument contains errors for multiple fields." "is a ValidationError with an error_dict."
) )
else: else:
error = error.error_dict error = error.error_dict
@ -316,7 +312,7 @@ class BaseForm(RenderableFormMixin):
field_id=self[field].auto_id, field_id=self[field].auto_id,
) )
self._errors[field].extend(error_list) 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] del self.cleaned_data[field]
def has_error(self, field, code=None): def has_error(self, field, code=None):