Skip to content
Snippets Groups Projects
Commit b1e27b20 authored by permcu's avatar permcu
Browse files

Reduce queries for teachers_and_subjects_table with prefetch

parent b70dea9d
No related branches found
No related tags found
1 merge request!422Resolve "Add export functionality to course book"
...@@ -3,7 +3,7 @@ from typing import Optional ...@@ -3,7 +3,7 @@ from typing import Optional
from copy import deepcopy from copy import deepcopy
from datetime import date, timedelta from datetime import date, timedelta
from django.db.models import Q from django.db.models import Q, Prefetch
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
from calendarweek import CalendarWeek from calendarweek import CalendarWeek
...@@ -175,12 +175,10 @@ def generate_full_register_printout( ...@@ -175,12 +175,10 @@ def generate_full_register_printout(
if include_teachers_and_subjects_table: if include_teachers_and_subjects_table:
group = group.prefetch_related( group = group.prefetch_related(
"courses", Prefetch("courses", queryset=Course.objects.select_related("subject")),
"courses__subject",
"courses__teachers", "courses__teachers",
"child_groups", "child_groups",
"child_groups__courses", Prefetch("child_groups__courses", queryset=Course.objects.select_related("subject")),
"child_groups__courses__subject",
"child_groups__courses__teachers", "child_groups__courses__teachers",
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment