Hello Django Users, I'm trying to learn Django as best as i can, however i've come to problem which i hope someone can help me with.
I have two models, Release and OTAP. A Release is a reference to a file and linked to an OTAP. An OTAP can have a Release for each of the 4 environments. I've modeled this as below: class Release(models.Model): name = models.CharField(max_length=128, unique=True, ) path = models.CharField(max_length=512, ) otap = models.ForeignKey('OTAP') class OTAP(models.Model): name = models.CharField(max_length=128, unique=True, ) o_release = models.ForeignKey(Release, verbose_name="O-Environment", related_name='o_release', null=True, blank=True) t_release = models.ForeignKey(Release, verbose_name="T-Environment", related_name='t_release', null=True, blank=True) a_release = models.ForeignKey(Release, verbose_name="A-Environment", related_name='a_release', null=True, blank=True) p_release = models.ForeignKey(Release, verbose_name="P-Environment", related_name='p_release', null=True, blank=True) This all works in the admin interface, i can select Releases for each OTAP i have for each of the 4 environments. However i would like to limit the choices of the environments to just those releases that belong to that OTAP. I've tried to work with the 'limit_choices_to' from the ForeignKey, but i've had no luck so far. I've tried to limit the Release to the otap field but i can't seem to figured out how to select the 'self' of OTAP. So my question is: how do i limit the choices for each environment to just those release belonging to the OTAP? I hope someone can point me in the right direction. Regards, Nick --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---