1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-01-25 05:54:27 +00:00
Hidden Z 96a3e480dc pyi2phosts/latest/views.py: move queryset to separate function
I'll use it later from another place.
2011-02-16 18:58:05 +00:00

28 lines
765 B
Python

import datetime
from django.views.generic import list_detail
import settings
from pyi2phosts.postkey.models import i2phost
def get_latest():
now_date = datetime.datetime.utcnow()
start_date = now_date - datetime.timedelta(days=settings.LATEST_DAY_COUNT)
qs = i2phost.objects.filter(activated=True,
date_added__range=(start_date, now_date)).order_by("-date_added")[:settings.LATEST_HOSTS_COUNT]
return qs
def latest(request):
return list_detail.object_list(
request = request,
queryset = get_latest(),
template_name = 'latest.html',
template_object_name = 'host',
paginate_by = 40,
extra_context = {
'title': settings.SITE_NAME,
'day_count': settings.LATEST_DAY_COUNT,
'hosts_count': settings.LATEST_HOSTS_COUNT,
}
)