Answer the question
In order to leave comments, you need to log in
How to check the uniqueness of data in ForeignKey fields?
This is my rather simple model with 6 fields for selecting a player in a team, so that later I can include the team in the match without adding players separately.
class Team(models.Model):
team_name = models.CharField(max_length=255)
t_1_id = models.ForeignKey(Player, related_name='+')
t_2_id = models.ForeignKey(Player, related_name='+')
t_3_id = models.ForeignKey(Player, blank=True, null=True, related_name='+')
t_4_id = models.ForeignKey(Player, blank=True, null=True, related_name='+')
t_5_id = models.ForeignKey(Player, blank=True, null=True, related_name='+')
t_6_id = models.ForeignKey(Player, blank=True, null=True, related_name='+')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question