From fca73608c2ba5f93cb2f8bee7bc3f50fb0f3adb4 2021-10-13 10:20:58 From: Ben Sturmfels Date: 2021-10-13 10:20:58 Subject: [PATCH] Count supporters in the database - it's faster. --- diff --git a/www/conservancy/frontpage.py b/www/conservancy/frontpage.py index e78386b8ae502a3aa32d56578f922f3c078d2ff8..758403929f3f53815c027e125dd59c1676e80e1c 100644 --- a/www/conservancy/frontpage.py +++ b/www/conservancy/frontpage.py @@ -13,7 +13,7 @@ def view(request): now = datetime.now() context = { 'press_releases': PressRelease.objects.all().filter(pub_date__lte=now, sites=2)[:5], - 'supporters_count': len(Supporter.objects.all().filter(display_until_date__gte=now)), + 'supporters_count': Supporter.objects.all().filter(display_until_date__gte=now).count(), 'blog': BlogEntry.objects.all().filter(pub_date__lte=now)[:5], } return render_template_with_context(request, "frontpage.html", context)