Paginating the results of a Django forms POST request

前端 未结 7 497
旧巷少年郎
旧巷少年郎 2020-12-04 13:39

I\'m using Django Forms to do a filtered/faceted search via POST, and I would like to Django\'s paginator class to organize the results. How do I preserve the original requ

7条回答
  •  醉话见心
    2020-12-04 14:15

    Have the search form and the results display on one single django template. Initially, use css to hide the results display area. On POSTing the form, you could check to see if the search returned any results and hide the search form with css if results exist. If results do not exist, use css to hide the results display area like before. In your pagination links, use javascript to submit the form, this could be as simple as document.forms[0].submit(); return false;

    You will need to handle how to pass the page number to django's paging engine.

提交回复
热议问题