Wednesday, September 7, 2011

Re: Pagination of more than one field


On 7 September 2011 08:25, OC <sagios@gmail.com> wrote:
also attaching relevant parts of view.py:


 movpagin = Paginator(movies, 12)

   page = int(request.GET.get('page','1'))
   try:
       moviesp = movpagin.page(page)
   except PageNotAnInteger:
       # If page is not an integer, deliver first page.
       moviesp = movpagin.page(1)
   except EmptyPage:
       # If page is out of range (e.g. 9999), deliver last page of
results.
       moviesp = movpagin.page(movpagin.num_pages)

   actpagin = Paginator(actors, 8)

   page = int(request.GET.get('page','1'))

There's the problem right there. You're using the same page variable for both sides, so inevitably you'll find they move together.

Put the movies page into a variable called movie_page, and the actors into actor_page. Update your links in the template to use the right query for the prev/next and all should work fine.

Malcolm 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment