Hi all - I have two models with a many-to-many relationship: Restaurant and Cuisine. The Cuisine table contains, e.g., "Italian", "Mexican", "Chinese", etc. Each Restaurant record can be associated with one or more Cuisines.
Here's the thing: I'd like to limit this to three Cuisines per Restaurant. So when editing the record for "Bob's Pan-Asian Buffet", the user would be able to check "Japanese", "Chinese", and "Korean", but wouldn't be able to check a fourth box. My question: can this be enforced within the model, or is this something I'd have to build into my interface layer? Here's my models.py. from django.db import models from django.contrib.auth.models import User class Restaurant( models.Model ): user = models.ForeignKey( User ) name = models.CharField( max_length = 128 ) slug = models.CharField( max_length = 24, unique = True ) cuisines = models.ManyToManyField( 'Cuisine' ) def __unicode__(self): return self.name class Cuisine( models.Model ): name = models.CharField( max_length = 32 ) def __unicode__(self): return self.name class Meta: ordering = ['name'] -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.