[Solved]-Get a queryset's current order_by ordering

19👍

You can retrieve the list of columns from order_by clause by accessing queryset.query.order_by property.

From django docs:

The query attribute is an opaque object. It represents the internals of the query construction and is not part of the public API. However, it is safe (and fully supported) to pickle and unpickle the attribute’s contents as described here.

Leave a comment