From 5260669693015e240cabc7340992e01a0ead741e Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 20 Mar 2021 11:26:44 +0100 Subject: [PATCH] Remove unnecessary query when not logged in --- articles/context_processors.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/articles/context_processors.py b/articles/context_processors.py index cb18c25..60d4725 100644 --- a/articles/context_processors.py +++ b/articles/context_processors.py @@ -11,6 +11,8 @@ IGNORED_PATHS = [ def drafts_count(request): if request.path in IGNORED_PATHS: return {} + if not request.user.is_authenticated: + return {} return {"drafts_count": Article.objects.filter(status=Article.DRAFT).count()}