django queryset aggregation count counting wrong thing
问题 This is a continuation question from: Django queryset get distinct column values with respect to other column My Problem: Using aggregate count in Django counts the wrong thing in the queryset, or as far as I can see something that is not even in my queryset. What I did I used: queryset.order_by('col1', 'col2').distinct('col1', 'col2').values('col2') to get the values of col2 of a model where all the rows have a distinct pair of values in (col1, col2) . There is an example in the link above.