[Answered ]-Django query annotate after filter doesn't work correctly

1👍

I found the answer to this problem in Django docs.

Apparently:

filter() and annotate() are not commutative operations.

I have to annotate all of the objects first, and then use filter on it; to almost get what I want.

But I still don’t know what should I do if I want to annotate a queryset that is not directly from the model’s manager.

👤aaronn

Leave a comment