Model managers and inheritance

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Model managers and inheritance

Lorenzo Peña
Hello everyone!

I know there must be a good reason to have managers outside of models and having the current rules for "manager inheritance" upon abstract/concrete model inheritance. However, there are legitimate cases where you want to use manager mixins (very much like model mixins) in order to compose manager functionality. And most of the time, at least to me, the need of model mixins and manager mixins in order to be composed for each model/manager feels like a bad design approach.

Consider the case someone needs abstract model mixins in order to have common fields composable, so that defining several models with common field patterns is done nicely by inheriting the mixins. Now consider the case someone needs to equally compose manager functionality, in a way that matches the abstract model functionality. The current way to do it is also creating several manager mixins and composing them into specific managers for each model. At one point one starts thinking that this could be done through a single mixin (for both fields and manager methods reuse.)

My questions:

- Can you point me to a page/thread where it's stated why we need external manager classes instead of mixing the manager functionality with the model class?
- Is there any way to work this design decision around, so that composing model and manager functionality can be done without having to create mixins for both?

Thank you very much!

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/01b93b73-52ba-48ff-96b3-56f82d66862d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.