diff options
author | Alban Gruin | 2018-01-27 22:02:32 +0100 |
---|---|---|
committer | Alban Gruin | 2018-01-27 22:02:32 +0100 |
commit | 1ba5cda81bfeb19c98b80f172dca5ddc0b64ab4c (patch) | |
tree | 28ab30c83f8183555333f2581c3c09c56183edfd | |
parent | 0aceecf04cf720525772a9801d7799f19e5a3cd1 (diff) |
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
-rw-r--r-- | models.py | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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") |