In Django I have a parent abstract class with a few common fields, and some subclasses that add more fields. In some of these subclasses I would like to add custom validators that validate fields on the parent class.
class Template(models.Model):
text = models.CharField(max_length=200)
class GlobalTemplate(Template):
function = models.ManyToManyField(Function, null=True, blank=True)
I can easily add them on the field in the parent class like this:
class Template(models.Model):
text = models.CharField(max_length=200, validators=[validate_custom])
But in this case I want to add the validator to my child class GlobalTemplate, but have it attached to the text field.
Is this possible in Django?
Thanks!