我在学习大坝的同时,正在建造一个足球预测器,其模式如下:
class Team(models.Model):
Name = models.CharField(max_length=30)
class Fixture(models.Model):
HomeTeam = models.ForeignKey(Team, related_name= HomeTeamRef )
AwayTeam = models.ForeignKey(Team, related_name= AwayTeamRef )
HomeTeamScore = models.IntegerField(null=True, blank=True)
AwayTeamScore = models.IntegerField(null=True, blank=True)
Date = models.DateField()
class Player(models.Model):
User = models.ForeignKey(User)
DefaultHomeScore = models.IntegerField()
DefaultAwayScore = models.IntegerField()
class Prediction(models.Model):
Fixture = models.ForeignKey(Fixture)
HomeTeamScore = models.IntegerField()
AwayTeamScore = models.IntegerField()
Date = models.DateTimeField()
Player = models.ForeignKey(Player)
我有许多固定装置物体有人居住,并且一直在使用基于预测模型的模型表格,以便形成一种使用户能够进入计分的观点。
问题是,他们必须选择与预测有关的哪一种办法。 我愿预先欢迎这一点,以便他们获得固定装置清单,并刚刚进入屋顶和离层。 这需要预先策划。 Fixture field and Prediction. 运动员们,但我对如何做到这一点感到不满?
任何帮助都受到高度赞赏。
Edit: The problems seems to be how to pass multiple instances of Fixture into a Prediction model formset, I have seen examples of passing one but would like to do this all in one go. I also would like the user to be able to make one Prediction per Fixture.