mirror of
https://github.com/django/django.git
synced 2025-11-18 02:56:45 +00:00
Merge eebdb0719c into 1ce6e78dd4
This commit is contained in:
commit
c63129bbe8
2 changed files with 15 additions and 2 deletions
|
|
@ -287,8 +287,8 @@ class BaseForm(RenderableFormMixin):
|
|||
if hasattr(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
|
||||
|
|
|
|||
|
|
@ -1710,6 +1710,19 @@ aria-describedby="id_birthday_error">
|
|||
},
|
||||
)
|
||||
|
||||
def test_add_error_validation_error_dict(self):
|
||||
class FooForm(Form):
|
||||
the_field = CharField(max_length=100)
|
||||
|
||||
exc = ValidationError({"the_field": "Something is wrong with the field."})
|
||||
form = FooForm()
|
||||
msg = (
|
||||
"The argument `field` must be `None` when the `error` argument "
|
||||
"is a ValidationError with an error_dict."
|
||||
)
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
form.add_error("the_field", exc)
|
||||
|
||||
def test_has_error(self):
|
||||
class UserRegistration(Form):
|
||||
username = CharField(max_length=10)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue