mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #23865 -- documented how to assign errors to a field in Model.clean()
Also added a unit test wit the simpler syntax which we have documented, where the dictionary values are strings.
This commit is contained in:
committed by
Tim Graham
parent
a3aeba0f95
commit
5b26a014a8
@@ -2269,6 +2269,13 @@ class ModelFormCustomErrorTests(TestCase):
|
||||
str(form.errors['name1']),
|
||||
'<ul class="errorlist"><li>Model.clean() error messages.</li></ul>'
|
||||
)
|
||||
data = {'name1': 'FORBIDDEN_VALUE2', 'name2': 'ABC'}
|
||||
form = CustomErrorMessageForm(data)
|
||||
self.assertFalse(form.is_valid())
|
||||
self.assertHTMLEqual(
|
||||
str(form.errors['name1']),
|
||||
'<ul class="errorlist"><li>Model.clean() error messages (simpler syntax).</li></ul>'
|
||||
)
|
||||
data = {'name1': 'GLOBAL_ERROR', 'name2': 'ABC'}
|
||||
form = CustomErrorMessageForm(data)
|
||||
self.assertFalse(form.is_valid())
|
||||
|
||||
Reference in New Issue
Block a user