diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2013-08-06 02:10:45 -0700 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2013-08-06 02:10:45 -0700 |
| commit | 0b771fcf2923cef1b0d759fda79907c39ad733b4 (patch) | |
| tree | 811f66c4c15a1a30097c895ede76f2477a6bc763 /tests/model_forms/models.py | |
| parent | 263b873599a50609df7865ff9cf24c63cd3e82d2 (diff) | |
| parent | 71093d22b62548fc2667468f1ae9e28f4fef30db (diff) | |
Merge pull request #1441 from loic/ticket16986
Fixed #16986 -- Model.clean() can report errors on individual fields.
Diffstat (limited to 'tests/model_forms/models.py')
| -rw-r--r-- | tests/model_forms/models.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py index a4cf9471de..17aec29055 100644 --- a/tests/model_forms/models.py +++ b/tests/model_forms/models.py @@ -12,7 +12,7 @@ import os import tempfile from django.core import validators -from django.core.exceptions import ImproperlyConfigured +from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.files.storage import FileSystemStorage from django.db import models from django.utils import six @@ -296,3 +296,7 @@ class CustomErrorMessage(models.Model): name2 = models.CharField(max_length=50, validators=[validators.validate_slug], error_messages={'invalid': 'Model custom error message.'}) + + def clean(self): + if self.name1 == 'FORBIDDEN_VALUE': + raise ValidationError({'name1': [ValidationError('Model.clean() error messages.')]}) |
