[Answered ]-Django model manager didn't work with related object when I do aggregated query

2👍

I have figured out what’s wrong and how to fix it now 🙂

  1. As stated in the Django doc:

Django interprets the first Manager defined in a class as the “default” Manager, and several parts of Django will use that Manager exclusively for that model.

In my case, I should make sure that SortedTagManager is the first Manager defined.

2.I should have count notes instead of users:

Count('notes', distinct=True)
👤satoru

Leave a comment