LINUX.ORG.RU

История изменений

Исправление x3al, (текущая версия) :

Но ведь можно было сделать статические методы для обращения к таблице и нестатические для обращения к конкретноу сущности.

http://www.b-list.org/weblog/2008/feb/25/managers/

But there are two much larger benefits from having these methods on a separate class:

It opens up the ability to define multiple sets of query behaviors, and choose between them as needed. So, for example, the Entry class might get two managers: one which queries on all entries, for use in the admin interface, and another which only queries on entries with is_live=True for public views. It provides an easy way to encapsulate patterns of behavior; if you commonly need to have a set of extra query methods, for example, or want to change the behavior of existing methods, you only need to write that code once — in a Manager subclass — and can reuse it on multiple models, rather than having to duplicate the logic every time you want to use it.

и http://stackoverflow.com/q/7692487/2815355 если мало.

Исправление x3al, :

Но ведь можно было сделать статические методы для обращения к таблице и нестатические для обращения к конкретноу сущности.

http://www.b-list.org/weblog/2008/feb/25/managers/

But there are two much larger benefits from having these methods on a separate class:

It opens up the ability to define multiple sets of query behaviors, and choose between them as needed. So, for example, the Entry class might get two managers: one which queries on all entries, for use in the admin interface, and another which only queries on entries with is_live=True for public views. It provides an easy way to encapsulate patterns of behavior; if you commonly need to have a set of extra query methods, for example, or want to change the behavior of existing methods, you only need to write that code once — in a Manager subclass — and can reuse it on multiple models, rather than having to duplicate the logic every time you want to use it.

Исходная версия x3al, :

Наверно, этой ссылкой можно было закрыть тред.

Но ведь можно было сделать статические методы для обращения к таблице и нестатические для обращения к конкретноу сущности.

http://www.b-list.org/weblog/2008/feb/25/managers/