One of the questions that has been bothering me for a long time is why are Manager and QuerySet not the same?
I know that Manager returns an object from QuerySet and QuerySet methods are iterable but Manager methods are not, but I still haven’t been able to understand the reason for creating Managers
According to what I saw in the Django core code, Manager is created from a QuerySet:
class Manager(BaseManager.from_queryset(QuerySet)):
pass
The document says that Manager is an abstraction layer between our Python code and database objects
I don’t understand the reason for creating this abstraction layer, so I have a few questions:
What is the reason for using this abstraction layer?
When should I overwrite Managers and when should I overwrite QuerySets?
Considering the answers to the questions above, what is the difference between the two? (They may be no different and complement each other’s work, but what is the difference between what they do?)
1 post - 1 participant