You know the select options like on ebay where they have 'best match', 'time ending soonest', etc. And when you choose an option the pages refreshes and returns the results in that order. How do you do that?
So far this is my 开发者_JS百科idea, I was going to store a session variable for the user and base on what the session variable is upon each refresh/http request, I could determine what the user wants. So I've got the session variable read/write down on the python/django side, but I have no idea how to set the session variable on the user side, say with jquery or something cuz I was thinking when the user selects an option, jquery sets the session variable and does a refresh, which is picked up by my django view which returns the correct sorted results.
I'm not sure (and it probably isn't) the best way to do this, so please help me out. Is there a better way of doing this and/or how do you do the client side of my idea?
Thanks !!!
You could just set the ordering via GET
. The template would have something like
<a href="?ordering=best">Best match</a>
<a href="?ordering=soonest">Ending soonest</a>
The view would check request.GET
and sort appropriately.
精彩评论