Hello everyone I just started with django and was wondering how to do the following behaivor in my models:
class Game(models.Model)
characters_count = models.IntegerField(default=1) #basically i set to a choice of 1-3
class Match(models.Model)
video=models.ForeignKey(Game)
p1char1 = models.ForeignKey(Character)
p2char1 = models.ForeignKey(Character)
p1char2 = models.ForeignKey(Character)
p2char2 = models.ForeignKey(Character)
p1char3 = models.ForeignKey(Character)
p2char3 = models.ForeignKey(Character)
video contains the instance game which Match relies on.
I need to create a constraint that the Character selected is from the given game and that the number of characters each player selects is limited by game as well.
Should I perform this on the Save method? or can I set these constraints some other way so the forms will be generated by the models accordingly without doing it manually.
Will the limitation on the characters (by the game) can be done on the definition of the model?