On August 27, 2016 5:48:26 PM GMT+02:00, Paulo Gabriel Poiati <
paulog...@gmail.com> wrote:
>Hello Aymeric,
>
>I think you are probably right, including it in Django itself will
>only benefit big projects. I mean, changing all the existing models
>to receive the DefaultManager is a burden depending on the project
>size. But we can overcome this by applying the “never extend
>models.Model directly” pattern.
Another argument against this feature would be that most Django
projects use a collection of third-party packages, or at least some
from django.contrib. Globally changing all models' default managers
wouldn't only affect your code, but also every package that's not
under your control. As long as you'd only add some logging, that might
be OK, but changing behavior in any way (like adding a default filter,
or changing the behavior of create, as you suggested in the original
post) would likely break those third-party packages with a lot of
potential for hard to find obscure issues. Unless, of course, you
explicitly whitelist only your models in that custom manager, and fall
back to the default behavior in other models, but that would rather
beat the purpose of this feature.
For customizations like this you're definitely better off opting in
with every single model (using your own base class) than changing all
models globally.
Cheers,
Michal