From 7aa5da28fe39f3d12b2201d64128a3f70b50854d Mon Sep 17 00:00:00 2001 From: "Andreas (@xAndy) Zimmermann" Date: Sun, 28 May 2023 12:24:31 +0200 Subject: [PATCH] reduce team shift view query count --- shiftregister/team/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shiftregister/team/views.py b/shiftregister/team/views.py index ff2721d..9d76d8b 100644 --- a/shiftregister/team/views.py +++ b/shiftregister/team/views.py @@ -93,7 +93,9 @@ def add_helper_shift(self): @login_required def shift_detail(request, pk): - shift = get_object_or_404(Shift, pk=pk) + shift = get_object_or_404( + Shift.with_reg_count().prefetch_related("shiftregistration_set__helper"), pk=pk + ) form = HelperShift() if request.method == "POST": form = HelperShift(request.POST)