python - Django - order existing search results according to user choices -


i'm creating django (1.8) web application lets end-users search entries. i've managed let users search results according input.

however, want users able order search results after results returned, according user's selection of choices (e.g. order distance, order rating, order price). i'm having trouble implementing because can't figure out logic behind this.

could please tell me how implement such feature please? thank much!

the simplest way .order_by('fieldname'). in template have links same page add parameters. in view check these parameters , decide how sort results. it'll this

model.objects.filter(field='value').order_by('sort-criteria') 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -