Wednesday, September 7, 2011

Re: Pagination of more than one field

Thank you very much for your reply,
I changed it but I guess Im doing something wrong cause it still
doesnt work:
It tries to go to the right page now, but provides nothing although I
know there's more than one page:

in views.py
movies_page= int(request.GET.get('page','1'))
try:
moviesp = movpaginator.page(movies_page).......

in the template:
{% if actors.has_previous %}
<a href="?
movies_page={{ actors.previous_page_number }}"><img
src="{{ MEDIA_URL }} images/preview.png"></a>
{% else %}


On 7 ספטמבר, 15:53, Malcolm Box <malcolm....@gmail.com> wrote:
> On 7 September 2011 08:25, OC <sag...@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