From 8cb027621506d5920b1efa9e02c654beebc8ad45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Tue, 21 Nov 2023 17:42:57 +0100 Subject: [PATCH] Use better way to find out if model record exists --- games/views.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/games/views.py b/games/views.py index ee7cb21..8fbda16 100644 --- a/games/views.py +++ b/games/views.py @@ -30,11 +30,11 @@ from .models import Edition, Game, Platform, Purchase, Session def model_counts(request): return { - "game_available": Game.objects.count() != 0, - "edition_available": Edition.objects.count() != 0, - "platform_available": Platform.objects.count() != 0, - "purchase_available": Purchase.objects.count() != 0, - "session_count": Session.objects.count(), + "game_available": Game.objects.exists(), + "edition_available": Edition.objects.exists(), + "platform_available": Platform.objects.exists(), + "purchase_available": Purchase.objects.exists(), + "session_count": Session.objects.exists(), }