mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #12512. Changed ModelForm to stop performing model validation on fields that are not part of the form. Thanks, Honza Kral and Ivan Sagalaev.
This reverts some admin and test changes from [12098] and also fixes #12507, #12520, #12552 and #12553. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12206 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
26279c5721
commit
2f9853b2dc
17 changed files with 427 additions and 135 deletions
|
@ -17,8 +17,8 @@ class ModelToValidate(models.Model):
|
|||
url = models.URLField(blank=True)
|
||||
f_with_custom_validator = models.IntegerField(blank=True, null=True, validators=[validate_answer_to_universe])
|
||||
|
||||
def validate(self):
|
||||
super(ModelToValidate, self).validate()
|
||||
def clean(self):
|
||||
super(ModelToValidate, self).clean()
|
||||
if self.number == 11:
|
||||
raise ValidationError('Invalid number supplied!')
|
||||
|
||||
|
@ -36,7 +36,7 @@ class UniqueTogetherModel(models.Model):
|
|||
efield = models.EmailField()
|
||||
|
||||
class Meta:
|
||||
unique_together = (('ifield', 'cfield',),('ifield', 'efield'), )
|
||||
unique_together = (('ifield', 'cfield',), ('ifield', 'efield'))
|
||||
|
||||
class UniqueForDateModel(models.Model):
|
||||
start_date = models.DateField()
|
||||
|
@ -51,3 +51,15 @@ class CustomMessagesModel(models.Model):
|
|||
error_messages={'null': 'NULL', 'not42': 'AAARGH', 'not_equal': '%s != me'},
|
||||
validators=[validate_answer_to_universe]
|
||||
)
|
||||
|
||||
class Author(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
class Article(models.Model):
|
||||
title = models.CharField(max_length=100)
|
||||
author = models.ForeignKey(Author)
|
||||
pub_date = models.DateTimeField(blank=True)
|
||||
|
||||
def clean(self):
|
||||
if self.pub_date is None:
|
||||
self.pub_date = datetime.now()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue