So I wrote an app that returns an the query results. Let’s assume the query URL is /query/?A=a&B=b
And now I want to add a “sort by” button to my results page to allow the users to sort the results by time, or type. Essentially just allow user to visit /query/?A=a&B=b&sorted=time or /query/?A=a&B=b&sorted=type
The easiest way is to append sorted= after the current URL. For example <a href = "{{ request.get_full_path }}&sorted=time"> But the problem is that if user first sorts by time, then sorts by type, you will have /query/?A=a&B=b&sorted=type&sorted=time
I suppose I can do some fancy string operations, but I don’t know if I can do that in django template language, and I suppose there is a better way of doing it. There should be somewhere I can just modify the GET request and let the page refresh.
Thanks a lot!
You might want to look at django-tables2’s solution (you might just want to look at django-tables2 in general if you’re displaying this data in a table).