Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django - the best way to combine pagination with filtering and request.POST - like stackoverflow - ajax?

Tags:

django

I want to combine pagination with filtering. Since I have a lot of filters I do not want to send them per GET request, since the URLs get really ugly.

Since django pagination uses GET request to pass the page parameters, I do not know how I can combine these two approaches.

Any idea?

Great add-on would be: How can I combine this approach with table sort? :-)

Edit:

Actually it should work like the pagination of stackoverflow - user questions. If a user clicks on a page number one is shown the correct page, without showing the get parameters in the url.

This is the url called. https://stackoverflow.com/api/userquestions.html?page=2&pagesize=10&userId=237690&sort=Recent

But the url shown in the browser is neat and short. Seems to be ajax. Anybody an idea how to implement this? :)

If the URL is not shown in the browser`s address bar, I do not care about whether it is beautiful or not.

Edit: The solution:

Make an ajax update with all filter parameters passed to the view. This should help you get started with implementing ajax for your site: link

Thus the GET parameters never show up in the address bar.

like image 367
Thomas Kremmel Avatar asked Jan 05 '10 13:01

Thomas Kremmel


2 Answers

have you checked the paginate application for django? it may help you a lot, use it all the time :D

http://code.google.com/p/django-pagination/

like image 87
PirosB3 Avatar answered Sep 17 '22 23:09

PirosB3


Have you considered django-tables2? It gives you django-admin style tables without you having to write the logic yourself.

like image 30
Wilfred Hughes Avatar answered Sep 19 '22 23:09

Wilfred Hughes