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

unix - grep command not match start of new line with another regex -

sql - calculate weighted average for each day and id based on time intervals in PostgreSQL -

Sort a complex associative array in PHP -