I'm trying to setup my first app and I'm trying to figure out the best way 
to have constraints on a particular field (strategy for class Division 
noted below).  Below is the basic model structure.  What I would like is 
for the strategy under a Division to be constrained to the strategies 
selected for the Business.  A business may have many strategies, but a 
division will only have one (but it should only be one selected for the 
business).  Any help on this would be appreciated.  Thanks, Sam

class Strategy(models.Model):
    name = models.CharField(max_length=200)

#name would be something like retail, wholesale, etc

class Business(models.Model):
   name = models.CharField()
   strategy = models.ManyToManyField(Strategy)

class Division(models.Model):
    business = models.ForeignKey(Business) 
    name = models.CharField()
    strategy = ???

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/sunwQb8Ft0cJ.
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.

Reply via email to