diff options
author | Alban Gruin | 2017-11-26 14:27:16 +0100 |
---|---|---|
committer | Alban Gruin | 2017-11-26 14:27:16 +0100 |
commit | 8cd40466e5b1ef9f00cf88c9375289d235abc009 (patch) | |
tree | 5b0c6ec8bbea4cf0fb8f22b60d95d6ab107e02f3 | |
parent | ef6f5e8517436b804265880b71a2ee88f9f5c179 (diff) |
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())
-rw-r--r-- | views.py | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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"] |