If we chain a call to filter() after a call to distinct(), the filter is applied to the query before the distinct. How do I filter the results of a query after applying distinct?
Example.objects.order_by('a','b').distinct('a').filter(b='something)
The where clause in the SQL resulting from filter() means the filter is applied to the query before the distinct. I want to filter the queryset resulting from the distinct.
This is probably pretty easy, but I just can't quite figure it out and I can't find anything on it.
Another way to ask the question is how do I return a distinct QuerySet and then filter it?
Example.objects.order_by('a','foreignkey__b').distinct('a').filter(foreignkey__b='something')