When to use a manager instead of a queryset with as_manager().

I’m currently refactoring some portions of a project I have and noticed that there are some common patterns in the queries I do, like filtering the user or filtering based on stuff of a FK. Replacing all this stuff got a bit annoying so I researched how to do it better and read about custom managers and querysets.

If I understand correctly the main difference between the two is that the first time you use a method from a manager it returns a queryset, and then if you continue you use the methods from the querysets, which means you’d have to implement the method twice if you wanted to do chain filtering… unless you used the queryset and called as_manager().

The question I have now is what are the reasons to use a manager instead of defining everything in a queryset and calling that method?

1 Like