forms - django paginate the original search result -


i'm using listview display search result, , using forms let user input search values, here problem: when search results, say, 50 items, , set item_per_page 30, got 2 pages, when click next page link, forgets former search request , shows me of items in page 2, how fix this? code below:

my form fields this:

<form method="get" action="{% url 'query_student' %}">       #the form fields </form>        

my pagination template:

{% if is_paginated %}         <div class="pages">                 {% if page_obj.has_previous %}                         <a href="/student/querystudent?page={{ page_obj.previous_page_number }}">previous</a>                 {% endif %}                 <span class="btnon">                         page {{ page_obj.number }}  total {{ page_obj.paginator.num_pages }}                  </span>                 {% if page_obj.has_next %}                         <a href="/student/querystudent?page={{ page_obj.next_page_number }}">>next</a>                 {% endif %}         </div> {% endif %} 

you missing query string form data

simplest solution use django-url-tools, in links previous/next page add:

{% load urls %}  ...  {% add_params request.get_full_path page=page_obj.previous_page_number %}  ...  {% add_params request.get_full_path page=page_obj.next_page_number %} 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -