Count supporters in the database - it's faster.

This commit is contained in:
Ben Sturmfels 2021-10-13 21:20:58 +11:00
parent 26682bc158
commit fca73608c2
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0

View file

@ -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)