#20932: Issues with model Manager and inheritance.
-------------------------------------+-------------------------------------
Reporter: loic84 | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by carljm):
I like the proposal loic84 outlined (and mjtamlyn further explained as
option 1); given the longstanding discrepancy between the docs and the
actual behavior, I think that's a reasonable level of backwards-
incompatibility (if well documented) to achieve more predictable behavior.
I think eliminating `_default_manager` is a much bigger backwards-
incompatibility for the reason loic84 mentioned, and I don't see that it
really gains us much. To me "normal inheritance plus default `objects`
added if no other manager" is fine.
The other aspect here is that as long as we have to re-instantiate
managers at every inheritance level in order to re-bind them to the
correct model class, none of this can really fairly be described as
"normal MRO" because it's a different instance at every level, which is
certainly not how attribute resolution via the MRO normally behaves. I
discussed briefly with loic84 in IRC the option of having managers
actually assign a descriptor to the class that would bind a manager
instance to the correct model class on access, to avoid this need for re-
binding in advance at every inheritance level. But that's definitely a
bigger change and would need exploration to see if it's feasible.
--
Ticket URL: <https://code.djangoproject.com/ticket/20932#comment:16>
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.3408f6287551db01b2d76477cd0655a6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.