Models optimiert

This commit is contained in:
Martin Bley
2026-09-13 08:51:38 +02:00
parent 99eaafff00
commit 5b7f847bc6
+11 -3
View File
@@ -37,6 +37,9 @@ class Competition(models.Model):
leagueName = models.CharField(max_length=128) leagueName = models.CharField(max_length=128)
season = models.CharField(max_length=4) season = models.CharField(max_length=4)
class Meta:
unique_together = ("leagueShortcut", "season")
def __unicode__(self): def __unicode__(self):
return (self.leagueShortcut) return (self.leagueShortcut)
@@ -62,6 +65,12 @@ class Match(models.Model):
group = models.IntegerField() group = models.IntegerField()
matchday = models.IntegerField() matchday = models.IntegerField()
matchday_name = models.CharField(max_length=128) matchday_name = models.CharField(max_length=128)
competition = models.ForeignKey(
Competition,
on_delete=models.CASCADE
)
idTeam1 = models.ForeignKey( idTeam1 = models.ForeignKey(
Team, related_name='+', Team, related_name='+',
on_delete=models.CASCADE on_delete=models.CASCADE
@@ -70,11 +79,10 @@ class Match(models.Model):
Team, related_name='+', Team, related_name='+',
on_delete=models.CASCADE on_delete=models.CASCADE
) )
pointsTeam1 = models.SmallIntegerField() pointsTeam1 = models.SmallIntegerField()
pointsTeam2 = models.SmallIntegerField() pointsTeam2 = models.SmallIntegerField()
finished = models.BooleanField() finished = models.BooleanField()
season = models.CharField(max_length=4)
leagueShortcut = models.CharField(max_length=12)
def __unicode__(self): def __unicode__(self):
return (str(self.matchID)) return (str(self.matchID))
@@ -121,7 +129,7 @@ class Score(models.Model):
return str(self.client) return str(self.client)
class chart(models.Model): class Chart(models.Model):
team = models.ForeignKey( team = models.ForeignKey(
Team, Team,
on_delete=models.CASCADE on_delete=models.CASCADE