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
@@ -381,6 +381,8 @@ class CustomErrorMessage(models.Model):
|
||||
def clean(self):
|
||||
if self.name1 == 'FORBIDDEN_VALUE':
|
||||
raise ValidationError({'name1': [ValidationError('Model.clean() error messages.')]})
|
||||
elif self.name1 == 'FORBIDDEN_VALUE2':
|
||||
raise ValidationError({'name1': 'Model.clean() error messages (simpler syntax).'})
|
||||
elif self.name1 == 'GLOBAL_ERROR':
|
||||
raise ValidationError("Global error message.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user