Model validation on update in django
I've created a model called Term and a validator for it, like this: from django.db import models from django.contrib.auth.models import User from django.core.exceptions import ValidationError def validate_insensitive_exist(value): exists = Term.objects.filter(word__iexact = value.lower()).exists() if exists == True: raise ValidationError("This term already exist.") class Term(models.Model): word = models.CharField(max_length=200, unique=True, validators=[validate_insensitive_exist]) related_term = models.ManyToManyField("self", null=True, blank=True) def __unicode__(self): return self.word def