[Django] #27875: Manager inheritance for multi-table inheritance model behaviour

6 views
Skip to first unread message

Django

unread,
Feb 23, 2017, 5:18:17 AM2/23/17
to django-...@googlegroups.com
#27875: Manager inheritance for multi-table inheritance model behaviour
-------------------------------------+-------------------------------------
Reporter: ek-init | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.10
Uncategorized |
Severity: Normal | Keywords: Manager inheritance
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The Managers documentation says:
> Managers from base classes are always inherited by the child class,
using Python’s normal name resolution order (names on the child class
override all others; then come names on the first parent class, and so
on).

> 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.

Django

unread,
Feb 23, 2017, 9:22:38 AM2/23/17
to django-...@googlegroups.com
#27875: Manager inheritance for multi-table inheritance model behaviour
-------------------------------------+-------------------------------------
Reporter: ek-init | Owner: nobody
Type: Bug | Status: closed
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution: invalid

Keywords: Manager inheritance | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* 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>

Django

unread,
Feb 23, 2017, 9:30:33 AM2/23/17
to django-...@googlegroups.com
#27875: Manager inheritance documentation doesn't mention
manager_inheritance_from_future
-------------------------------------+------------------------------------

Reporter: ek-init | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.10
Severity: Normal | Resolution:
Keywords: Manager inheritance | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Tim Graham):

* 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>

Django

unread,
Feb 23, 2017, 10:05:50 AM2/23/17
to django-...@googlegroups.com
#27875: Manager inheritance documentation doesn't mention
manager_inheritance_from_future
-------------------------------------+------------------------------------
Reporter: ek-init | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.10
Severity: Normal | Resolution:
Keywords: Manager inheritance | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Tim Graham):

* 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>

Django

unread,
Feb 24, 2017, 4:15:45 PM2/24/17
to django-...@googlegroups.com
#27875: Manager inheritance documentation doesn't mention
manager_inheritance_from_future
-------------------------------------+------------------------------------
Reporter: ek-init | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.10
Severity: Normal | Resolution: fixed
Keywords: Manager inheritance | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by GitHub <noreply@…>):

* 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>

Django

unread,
Feb 24, 2017, 4:17:05 PM2/24/17
to django-...@googlegroups.com
#27875: Manager inheritance documentation doesn't mention
manager_inheritance_from_future
-------------------------------------+------------------------------------
Reporter: ek-init | Owner: nobody

Type: Bug | Status: closed
Component: Documentation | Version: 1.10
Severity: Normal | Resolution: fixed
Keywords: Manager inheritance | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------

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>

Django

unread,
Feb 27, 2017, 5:18:02 AM2/27/17
to django-...@googlegroups.com
#27875: Manager inheritance documentation doesn't mention
manager_inheritance_from_future
-------------------------------------+------------------------------------
Reporter: ek-init | Owner: nobody

Type: Bug | Status: closed
Component: Documentation | Version: 1.10
Severity: Normal | Resolution: fixed
Keywords: Manager inheritance | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages