mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@10878 bcc190cf-cafb-0310-a4f2-bffc1f526a37
17 lines
484 B
Python
17 lines
484 B
Python
from datetime import datetime
|
|
|
|
from django.core.exceptions import ValidationError
|
|
from django.db import models
|
|
from django.test import TestCase
|
|
|
|
class ModelToValidate(models.Model):
|
|
name = models.CharField(max_length=100)
|
|
created = models.DateTimeField(default=datetime.now)
|
|
number = models.IntegerField()
|
|
|
|
def validate(self):
|
|
super(ModelToValidate, self).validate()
|
|
if self.number == 11:
|
|
raise ValidationError('Invalid number supplied!')
|
|
|