How to limit manytomanyfields on a model ?

Posted by Tom on Stack Overflow See other posts from Stack Overflow or by Tom
Published on 2010-04-27T13:45:02Z Indexed on 2010/05/14 0:54 UTC
Read the original article Hit count: 243

Filed under:
|

I would like to check that I get not more than 3 relations set on a manytomanyfield.

I tried on the clean method to do this :

if self.tags.count()>3:
  raise ValidationError(_(u'You cannot add more than 3 tags'))

But self.tags returns not the current updates... only saved objects.

Do you have an idea to access to them ?

Thanks

© Stack Overflow or respective owner

Related posts about django

Related posts about manytomanyfield