From d81699719c35a24fc2c7917b8d147e332929ce31 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Mon, 14 Jun 2021 15:44:59 +0530 Subject: prefetch students, requests, rejected --- yaksh/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yaksh/views.py b/yaksh/views.py index 5761f37..3727514 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1185,7 +1185,9 @@ def course_detail(request, course_id): if not is_moderator(user): raise Http404('You are not allowed to view this page') - course = get_object_or_404(Course, pk=course_id) + course = Course.objects.prefetch_related( + 'students', 'requests', 'rejected' + ).get(id=course_id) if not course.is_creator(user) and not course.is_teacher(user): raise Http404('This course does not belong to you') -- cgit