diff options
author | Alban Gruin | 2017-11-26 13:27:40 +0100 |
---|---|---|
committer | Alban Gruin | 2017-11-26 13:27:40 +0100 |
commit | 34ba9c926cfd0725ebd2905e9c71823fd272dad2 (patch) | |
tree | 8d29a420ed8be07441d212d042907e227b45b798 | |
parent | 630bebd114cdbae7af736e117e2b10b7e9195657 (diff) |
Optimisation de deux requêtes :
– sélection des cours d’un groupe : préchargement des
salles
– sélection des emplois du temps d’une année : préchargement de
l’année
-rw-r--r-- | models.py | 2 | ||||
-rw-r--r-- | views.py | 2 |
2 files changed, 2 insertions, 2 deletions
@@ -152,7 +152,7 @@ class CourseManager(Manager): def get_courses_for_group(self, group, **criteria): return self.get_queryset() \ .filter(groups__in=Group.objects.get_parents(group), **criteria) \ - .order_by("begin") + .order_by("begin").prefetch_related("rooms") def get_weeks(self, **criteria): return self.get_queryset() \ @@ -31,7 +31,7 @@ def index(request): def mention_list(request, year_slug): year = get_object_or_404(Year, slug=year_slug) - timetables = Timetable.objects.order_by("name").filter(year=year) + timetables = Timetable.objects.order_by("name").filter(year=year).select_related("year") return render(request, "index.html", {"year": year, "elements": timetables}) |