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 = mod开发者_运维问答els.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
ForeignKey
's limit_choices_to
argument will allow you to limit the choices available via the admin interface.
精彩评论