views:

34

answers:

1

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

+2  A: 

ForeignKey's limit_choices_to argument will allow you to limit the choices available via the admin interface.

Ignacio Vazquez-Abrams