aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-11-27 16:37:31 +0100
committerAlban Gruin2017-11-27 16:37:31 +0100
commitfb6ea65e7d32dcf3d697e6c63985a018ada4d6b1 (patch)
treeca73e9ae756f1a06e857ac5caee2bcd2066705e9 /models.py
parent3b9eab819c603b1d3b2b59d79258ce6a05aa24b9 (diff)
Ajout d’un gestionnaire pour Timetable récupérant automatiquement les
années Réduit considérablement le nombre d’appels effectués dans l’interface d’administration
Diffstat (limited to 'models.py')
-rw-r--r--models.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/models.py b/models.py
index 6124b59..b8c67d6 100644
--- a/models.py
+++ b/models.py
@@ -62,7 +62,14 @@ class Source(models.Model):
verbose_name_plural = "sources d’emploi du temps"
+class TimetableManager(Manager):
+ def get_queryset(self):
+ return super(Manager, self).get_queryset().select_related("year")
+
+
class Timetable(SlugModel):
+ objects = TimetableManager()
+
year = models.ForeignKey(Year, on_delete=models.CASCADE,
verbose_name="année")
name = models.CharField(max_length=64, verbose_name="nom")