mirror of https://github.com/r4sas/py-i2phosts
Browse Source
This should fix problem with datetime.datetime.utcnow() evaluation caching in queryset.pull/1/head
Hidden Z
14 years ago
4 changed files with 30 additions and 17 deletions
@ -0,0 +1,5 @@ |
|||||||
|
from django.conf.urls.defaults import * |
||||||
|
|
||||||
|
urlpatterns = patterns('pyi2phosts.latest.views', |
||||||
|
url(r'^$', 'latest', name='latest'), |
||||||
|
) |
@ -0,0 +1,24 @@ |
|||||||
|
import datetime |
||||||
|
|
||||||
|
from django.views.generic import list_detail |
||||||
|
|
||||||
|
import settings |
||||||
|
from pyi2phosts.postkey.models import i2phost |
||||||
|
|
||||||
|
def latest(request): |
||||||
|
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 list_detail.object_list( |
||||||
|
request = request, |
||||||
|
queryset = qs, |
||||||
|
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, |
||||||
|
} |
||||||
|
) |
Loading…
Reference in new issue