[Django]-Django – How to find which field(s) a queryset is being ordered by?

4👍

You can get the list of ordering criteria, accessing the query object:

>>> qs = Store.objects.order_by('name', '-id')
>>> print qs.query.order_by
['name', '-id']

Leave a comment