From 78c43029707a6ef4a0777ceead19a9f016d9b7c5 Mon Sep 17 00:00:00 2001 From: retroinspect Date: Thu, 9 Mar 2023 17:09:19 +0000 Subject: [PATCH] Add prefetch attachment --- apps/core/views/viewsets/article.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/core/views/viewsets/article.py b/apps/core/views/viewsets/article.py index 01070933..c1eb9a5b 100644 --- a/apps/core/views/viewsets/article.py +++ b/apps/core/views/viewsets/article.py @@ -94,6 +94,10 @@ def filter_queryset(self, queryset): name_type=BoardNameType.ANONYMOUS ) + queryset = queryset.prefetch_related( + 'attachments' + ) + # optimizing queryset for list action queryset = queryset.select_related( 'created_by',