> If no managers are declared on a model and/or its parents, Django
automatically creates the objects manager.
For abstract base classes this works properly, inheriting the manager from
the base model and therefore overriding the objects manager if so
declared.
For my non-abstract inheritance example, this does not work the same way
...
{{{
#!python
class MyManager(models.Manager):
pass
class A(models.Model):
objects = MyManager()
other = MyManager()
class B(A):
pass
}}}
{{{
In [4]: B.objects.__class__
Out[4]: django.db.models.manager.Manager
In [5]: B.other.__class__
Out[5]: test_app.models.MyManager
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27875>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
You are using Django < 1.10 while reading the documentation for Django >=
1.10.
As the [https://docs.djangoproject.com/en/1.10/topics/db/managers/#custom-
managers-and-model-inheritance Django 1.10 documentation mentions]:
> In older versions, manager inheritance varied depending on the type of
model inheritance (i.e. Abstract base classes, Multi-table inheritance, or
Proxy models), especially with regards to electing the default manager.
--
Ticket URL: <https://code.djangoproject.com/ticket/27875#comment:1>
* status: closed => new
* resolution: invalid =>
* stage: Unreviewed => Accepted
* component: Uncategorized => Documentation
Comment:
Actually, the behavior is as documented but only when using
`Meta.manager_inheritance_from_future=True`. The documentation needs to
mention this. I'll propose a patch.
--
Ticket URL: <https://code.djangoproject.com/ticket/27875#comment:2>
* has_patch: 0 => 1
Comment:
My [https://github.com/django/django/pull/8104 PR] is intentionally vague
as it's difficult to tell which specific behaviors are controlled by the
attribute since there were a several manager changes spread over two
commits: 3a47d42fa33012b2156bf04058d933df6b3082d2 and
ed0ff913c648b16c4471fc9a9441d1ee48cb5420.
--
Ticket URL: <https://code.djangoproject.com/ticket/27875#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"22eb15a18c16b93496f6e88ebe3a306daad492b1" 22eb15a1]:
{{{
#!CommitTicketReference repository=""
revision="22eb15a18c16b93496f6e88ebe3a306daad492b1"
[1.11.x] Fixed #27875 -- Doc'd manager_inheritance_from_future in manager
docs.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27875#comment:4>
Comment (by Tim Graham <timograham@…>):
In [changeset:"e298ec4e947c3d300f4ef21019e59f4bc05ceabf" e298ec4]:
{{{
#!CommitTicketReference repository=""
revision="e298ec4e947c3d300f4ef21019e59f4bc05ceabf"
[1.10.x] Fixed #27875 -- Doc'd manager_inheritance_from_future in manager
docs.
Backport of 22eb15a18c16b93496f6e88ebe3a306daad492b1 from stable/1.11.x
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27875#comment:5>
Comment (by ek-init):
Replying to [comment:1 Simon Charette]:
> You are using Django < 1.10 while reading the documentation for Django
>= 1.10.
>
> As the [https://docs.djangoproject.com/en/1.10/topics/db/managers
/#custom-managers-and-model-inheritance Django 1.10 documentation
mentions]:
>
> > In older versions, manager inheritance varied depending on the type of
model inheritance (i.e. Abstract base classes, Multi-table inheritance, or
Proxy models), especially with regards to electing the default manager.
Fixed, but I want to mention that I was using Django 1.10.5 :)
--
Ticket URL: <https://code.djangoproject.com/ticket/27875#comment:6>