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

I want to combine pagination with filtering. Since I have a lot of filters, I don’t want to send them on a GET request, as the URLs become very ugly.

Since django pagination uses a GET request to pass page parameters, I don’t know how I can combine these two approaches.

Any idea?

A great addition would be: How can I combine this approach with table sorting ?:-)

Edit:

In fact, it should work like pagination stackoverflow - user questions. If the user clicks on the page number, the correct page is displayed without showing the retrieval options in the URL.

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

But the URL displayed in the browser is neat and short. It seems to be ajax. Does anyone know how to implement this? :)

If the URL does not appear in the address bar of the browser, I don't care if it is beautiful or not.

Edit: Solution:

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

Thus, GET parameters are never displayed in the address bar.

+7
django
source share
4 answers

Have you checked the paginate app for django? this may help you, use it all the time: D

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

+5
source share

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

+2
source share
0
source share

I figured out two solutions:

  • Instead of using only hyperlinks, use it inside the POST form, now I have no example, but I remember what I used for REST functions in Ruby on rails
  • Save request information in a session.

I hope for this help.

0
source share

All Articles