From d53ac1ef7a9a3c1e9a978b344a4947b53170a1a3 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 20 Mar 2021 11:36:26 +0100 Subject: [PATCH] Prefetch tags in articles admin --- articles/admin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/articles/admin.py b/articles/admin.py index f483d69..cd557c3 100644 --- a/articles/admin.py +++ b/articles/admin.py @@ -71,6 +71,12 @@ class ArticleAdmin(admin.ModelAdmin): change_form_template = "articles/article_change_form.html" search_fields = ["title", "content", "tags__name"] autocomplete_fields = ["tags"] + show_full_result_count = False + + def get_queryset(self, request): + queryset = super().get_queryset(request) + queryset = queryset.prefetch_related("tags") + return queryset def publish(self, request, queryset): if not request.user.has_perm("articles.change_article"):