From 5b7f847bc63b8a560fbd53b769f10c162d483dae Mon Sep 17 00:00:00 2001 From: Martin Bley Date: Sun, 13 Sep 2026 08:51:38 +0200 Subject: [PATCH] Models optimiert --- tipp/models.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tipp/models.py b/tipp/models.py index 94ea07e..b1b816e 100644 --- a/tipp/models.py +++ b/tipp/models.py @@ -37,6 +37,9 @@ class Competition(models.Model): leagueName = models.CharField(max_length=128) season = models.CharField(max_length=4) + class Meta: + unique_together = ("leagueShortcut", "season") + def __unicode__(self): return (self.leagueShortcut) @@ -62,6 +65,12 @@ class Match(models.Model): group = models.IntegerField() matchday = models.IntegerField() matchday_name = models.CharField(max_length=128) + + competition = models.ForeignKey( + Competition, + on_delete=models.CASCADE + ) + idTeam1 = models.ForeignKey( Team, related_name='+', on_delete=models.CASCADE @@ -70,11 +79,10 @@ class Match(models.Model): Team, related_name='+', on_delete=models.CASCADE ) + pointsTeam1 = models.SmallIntegerField() pointsTeam2 = models.SmallIntegerField() finished = models.BooleanField() - season = models.CharField(max_length=4) - leagueShortcut = models.CharField(max_length=12) def __unicode__(self): return (str(self.matchID)) @@ -121,7 +129,7 @@ class Score(models.Model): return str(self.client) -class chart(models.Model): +class Chart(models.Model): team = models.ForeignKey( Team, on_delete=models.CASCADE