website/www/frontpage.py

22 lines
669 B
Python
Raw Normal View History

2016-11-28 19:53:27 +00:00
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.
"""
2016-11-28 19:53:27 +00:00
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)