#25897: Managers defined on non-abstract base classes are in fact inherited by
child classes.
-------------------------------------+-------------------------------------
     Reporter:  poleha               |                    Owner:  poleha
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  manager,             |             Triage Stage:  Accepted
  inheritance                        |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by timgraham):

 Looking at the original commit where the documentation was added,
 f31425e8e23621fd4329c7377c9e220f526a1c49, it looks like named managers
 were always inherited. What does seem to work is that the default manager
 is never inherited.

 The test case in the commit looks like this:
 {{{
 class Parent(models.Model):
     manager = OnlyFred()

 # Will not inherit default manager from parent.
 class Child7(Parent):
     pass

 >>> Parent._default_manager.all()
 [<Parent: fred>]

 >>> Child7._default_manager.order_by('name')
 [<Child7: barney>, <Child7: fred>]

 >>> Child7.manager.all()
 [<Parent: fred>]

 >>> Child7._default_manager.order_by('name')
 [<Child7: barney>, <Child7: fred>]
 }}}

 I wonder if the behavior should actually be changed (which will cause
 backwards incompatibility for anyone relying on it) or if the
 documentation should be fixed? Maybe we should ask on the
 DevelopersMailingList.

--
Ticket URL: <https://code.djangoproject.com/ticket/25897#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.9b66555f60cfac13962adbb97fc3dcd6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to