On Fri, 2007-03-23 at 17:14 +0100, Alessandro Ronchi wrote:
> Hi to all.
>
> I've add a generic list view with:
> # Picture list:
> (r'^museo/galleria/(?P<page>[0-9]+)/$',
> 'django.views.generic.list_detail.object_list',
> dict(picture_list_info)),
>
> and I want to add previous and next links.
>
> It seems I must write an absolute url, in template, with:
> {% if has_previous %}<a
> href="http://localhost:8000/museo/galleria/{{previous}}">Pagina
> Precedente</a>{% endif %}
> {% if has_next %}<a
> href="http://localhost:8000/museo/galleria/{{next}}">Pagina
> Successiva</a>{% endif %}
>
>
> Now I want to paginate the results of a search. The search use the
> request.POST to filter results:
>
> if request.POST['title'] != '':
> query = query.filter(title__icontains=request.POST['title'])
>
> and then:
> return object_list(request, queryset=query)
>
> how can I show the second page of my search results?
>
> I've searched a lot on documentation, without results...
Did you read this?
http://www.djangoproject.com/documentation/generic_views/#notes-on-pagination
That describes how to make pagination work by default with generic
views. You need to pass in an optional page parameter as part of the
results you capture from the URL. You might set up your URLS to look
like /galleria/?page=2, or /galleria/2 or whatever you like -- just make
sure you capture the "page" variable in the URL parsing, if it is
present.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---