mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #12698. Model.clean() used with a ModelForm no longer causes a KeyError when raising a ValidationError.
Note that previously it was possible to raise a ValidationError in the same place with a message_dict attribute. That behavior was a bug and will no longer have the same behavior. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12402 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import os
|
||||
from django.db import models
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
|
||||
class Person(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
@@ -37,3 +39,11 @@ class CustomFileField(models.FileField):
|
||||
|
||||
class CustomFF(models.Model):
|
||||
f = CustomFileField(upload_to='unused', blank=True)
|
||||
|
||||
class RealPerson(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
def clean(self):
|
||||
if self.name.lower() == 'anonymous':
|
||||
raise ValidationError("Please specify a real name.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user