#27875 closed Bug (fixed)
Manager inheritance documentation doesn't mention manager_inheritance_from_future
Reported by: | ek-init | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.10 |
Severity: | Normal | Keywords: | Manager inheritance |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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 ...
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
Change History (6)
follow-up: 6 comment:1 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 8 years ago
Component: | Uncategorized → Documentation |
---|---|
Resolution: | invalid |
Status: | closed → new |
Summary: | Manager inheritance for multi-table inheritance model behaviour → Manager inheritance documentation doesn't mention manager_inheritance_from_future |
Triage Stage: | Unreviewed → Accepted |
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.
comment:3 by , 8 years ago
Has patch: | set |
---|
My 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.
comment:6 by , 8 years ago
Replying to Simon Charette:
You are using Django < 1.10 while reading the documentation for Django >= 1.10.
As the 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 :)
You are using Django < 1.10 while reading the documentation for Django >= 1.10.
As the Django 1.10 documentation mentions: