mercredi 28 mai 2014

Django filter queryset not fetching after pagination


Vote count:

0





lis = List.objects.get(id=request.GET.get('id'))
subs = Subscriber.objects.filter(id__in = subscriber_list)
paginator = Paginator(subs, rows)
list_of_id=[str(i) for i in subs.values_list('id')]
page = request.GET.get('page')
try:
paged_subs = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
paged_subs = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
paged_subs = paginator.page(paginator.num_pages)
pages=paged_subs.paginator.num_pages


When i tried to get the object list it shows empty. So i read about lazy queryset. But If i used Subscriber.objects.all() then it works perfectly.Please help.I have to loop through object_list before sending the HttpResponse. Am using Django 1.7 beta version



print(paged_subs.object_list)


shows []



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire