Doc here:
https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ManyToManyField
ManyToManyField does not support validators.
Is there a particular reason that ManyToManyField doesn't support validators? I would like to add a validator to require the user to select at least 3 options, but it seems the field simply doesn't run validators. I attempted to add one in like this:
from django.core.exceptions import ValidationError
def validate_three(value):
if len(value) < 3:
raise ValidationError("Must choose three related posts")
BlogPost._meta.get_field('related_posts').validators.append(validate_three)
But when it validates the field later, it says that self.validators == []