from datetime import datetime from django.shortcuts import render from .blog.models import Entry from .news.models import PressRelease from .supporters.models import Supporter def view(request): """Conservancy front page view Performs all object queries necessary to render the front page. """ now = datetime.now() context = { 'press_releases': PressRelease.objects.all().filter(pub_date__lte=now, sites=2)[:5], 'supporters_count': Supporter.objects.all().filter(display_until_date__gte=now).count(), 'blog': Entry.objects.all().filter(pub_date__lte=now)[:5], } return render(request, "frontpage.html", context)