From 1ba5cda81bfeb19c98b80f172dca5ddc0b64ab4c Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sat, 27 Jan 2018 22:02:32 +0100 Subject: Préchargement des salles et des groupes des cours lorsqu’on liste les cours d’une salle pour économiser les requêtes et augmenter les performances --- models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models.py b/models.py index 8ff9359..5d2fe17 100644 --- a/models.py +++ b/models.py @@ -198,7 +198,8 @@ class CourseManager(Manager): qs = qs.filter(groups__in=Group.objects.get_parents(obj), **criteria).prefetch_related("rooms") elif isinstance(obj, Room): - qs = qs.filter(rooms__in=(obj,), **criteria) + qs = qs.filter(rooms=obj, **criteria).prefetch_related("rooms", + "groups") else: raise(TypeError, "obj must be a Group or a Room") -- cgit v1.2.1