SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 4313304f authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Reduce commentaries list view db load

The select_related method reduces the database load
 by a factor of +/- 5 on the list view.
parent b7a5af75
No related branches found
No related tags found
No related merge requests found
......@@ -282,7 +282,9 @@ class CommentaryListView(ListView):
context = super().get_context_data(**kwargs)
# Get newest comments
context['comment_list'] = Comment.objects.vetted().order_by('-date_submitted')[:10]
context['comment_list'] = Comment.objects.vetted().select_related(
'author__user', 'submission', 'commentary').order_by(
'-date_submitted')[:10]
# Form into the context!
context['form'] = self.form
......
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