From 8cd40466e5b1ef9f00cf88c9375289d235abc009 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 26 Nov 2017 14:27:16 +0100 Subject: Optimisation de la requête utilisée pour savoir si il y a des cours sur la semaine sélectionnée (utilisation de exists() au lieu de count()) --- views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views.py b/views.py index 4431891..c647fac 100644 --- a/views.py +++ b/views.py @@ -77,7 +77,7 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No group = get_object_or_404(Group, slug=group_slug, timetable=timetable) courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) - if courses.count() == 0 and provided_week: + if not courses.exists() and provided_week: raise Http404 last_update = courses.aggregate(Max("last_update"))["last_update__max"] -- cgit v1.2.1