[Answered ]-Django limit the choice of a filed from one of the two Foreignkeys in a model

2👍

✅

Personally, I would separate them out and handle the limitation in the view.

Something like this:

class Match(models.Model):
    p1 = models.ForeignKey(Player , related_name='player1')
    p2 = models.ForeignKey(Player  ,related_name='player2')

class Game(models.Model):
    match = models.ForeignKey(Match)
    winner = models.ForeignKey(Player)

Then handle which Players are available to be designated Winner, based on the match. That’s just my take on it.

Leave a comment