Hello all. I'm having trouble getting pagination working on search results in a custom view.
I have djapian/xapian full-text indexing working and I have some pagination code cobbled together from various sources. I can get the search results and all the pagination (result count, page x of y, etc) happening on my template, but I'm getting ALL the search results on the the first page even if I paginate by 1. Also, if I click to page two, I get nothing but the blank search form. I'm pretty sure the problem lies in my views.py (below). Any help would be appreciated. views.py---------------------------------------------- from myproject.Catalog.models import Product_index from xapian import QueryParser from django import newforms as forms from django.core.paginator import Paginator, InvalidPage from django.template.context import RequestContext, Context from django.core.context_processors import request from django.http import Http404 class SearchForm(forms.Form): query = forms.CharField(label="") def search(request): if request.method == 'POST': query = request.POST.get('query') f = SearchForm(request.POST) search_flags = QueryParser.FLAG_PHRASE | QueryParser.FLAG_BOOLEAN results = Product_index.search(query, flags=search_flags) paginator = Paginator(results, 1) try: pager = int(request.GET.get('pager', '1')) results = paginator.page(pager) except InvalidPage: raise Http404 return render_to_response('Catalog/search.html', { 'paginator': paginator, 'results': results, 'form': f, 'is_paginated': paginator.num_pages > 1, 'has_next': results.has_next(), 'has_previous': results.has_previous(), 'current_page': pager, 'next_page': pager + 1, 'previous_page': pager - 1, 'pages': paginator.num_pages, 'count' : paginator.count, }, context_instance = RequestContext(request)) else: f = SearchForm() return render_to_response('Catalog/search.html', {'form': f}) end views.py-------------------------------------------------- urls.py---------------------------------------------------------- ... urlpatterns = patterns('', (r'^Catalog/search/$','myproject.Catalog.views.search'), ) end urls.py---------------------------------------------------- Let me know if there's any other relevant info I should add to this post. Thanks! ME --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---