How can I remove Model Meta ordering in Django or get the original queryset from the built in Manager? -


i have model uses meta ordering property make sure views use display things in same order.

however, have 1 method needs use distinct() method - not work after ordering applied. there built in way retrieve original queryset before ordering applied, or need write custom manager class allow me this.

call order_by() before distinct() no parameters.

from: https://docs.djangoproject.com/en/1.5/ref/models/querysets/#order-by

if don’t want ordering applied query, not default ordering, call order_by() no parameters.

just doing quick test reveals if foomodel.objects.order_by().distinct('bar') correctly removes order by clauses, ones defined in foomodel's meta.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -