Making only a part of model field available in Django

Posted by Hellnar on Stack Overflow See other posts from Stack Overflow or by Hellnar
Published on 2010-05-23T16:45:31Z Indexed on 2010/05/23 16:50 UTC
Read the original article Hit count: 482

Hello I have a such model:

GENDER_CHOICES = ( ('M', 'Male'), ('F', 'Female') )

class Profile(models.Model):
    user = models.ForeignKey(User)
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES)

class FrontPage(models.Model):
    female = models.ForeignKey(User,related_name="female")
    male = models.ForeignKey(User,related_name="male")

Once I attempt to add a new FrontPage object via the Admin page, I can select "Female" profiles for the male field of FrontPage, how can I restrict that?

Thanks

© Stack Overflow or respective owner

Related posts about python

Related posts about django