vendredi 29 décembre 2017

How to re-sort search results in-place without having to re-send a request in django?

Here is the scenario:

I have a search page, with some form elements providing multiple filter conditions (something like 'advanced search'), and probably a nested ListView to display the search results in-place. What I would like to achieve:

  1. Whenever the user changes some filter conditions, the result list below responds in-place (taking another request for this could be accepted);
  2. When the user changes the sorting option, the results change their ordering immediately, without sending another request, either synchronous or by ajax. From the server side it would be as simple as changing the order_by attribute of a QuerySet, but I would like it in a front-end way.

So I wonder if it is possible to achieve that. It seems to me that the filtered QuerySet could be somehow kept at the client side.

Is it possible by pure Django using some mechanism like session? Or will it have to take some front-end frameworks such as AngularJS or Vue.js? Or is it not even possible (If so, is there any approach taking the minimal extra network payload?)




Aucun commentaire:

Enregistrer un commentaire