Django: Order_by multiple fields
Solution 1:
Try something like this
modelclassinstance.objects.order_by('check-in', 'check-out', 'location')
You don't need .all()
for this
You can also define ordering in your model class
something like
class Meta:
ordering = ['check-in', 'check-out', 'location']
Solution 2:
Pass orders list in query parameters
eg : yourdomain/?order=location&order=check-out
default_order = ['check-in'] #default order
order = request.GET.getlist('order', default_order)
modelclassinstance.objects.all().order_by(*orderbyList)