I am getting order_by fields in the form of a list. I want to order_by by multiple fields with django orm. List is like below:
orderbyList = ['check-in','check-out','location']
I am writing a query is like:
modelclassinstance.objects.all().order_by(*orderbyList)
Everything i am expecting in a list is dynamic. I don't have predifined set of data.Could some tell me how to write a django ORM with this?
Try this:
Try something like this
You don't need
.all()
for thisYou can also define ordering in your model class
something like
Pass orders list in query parameters
eg : yourdomain/?order=location&order=check-out