Re: [Django] #10506: Automatically use correct auto-manager class for inherited models

4 views
Skip to first unread message

Django

unread,
Jan 12, 2016, 9:03:52 AM1/12/16
to django-...@googlegroups.com
#10506: Automatically use correct auto-manager class for inherited models
-------------------------------------+-------------------------------------
Reporter: mtredinnick | Owner:
| mtredinnick
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by poleha):

Replying to [ticket:10506 mtredinnick]:
> When creating a subclass of a model with a default manager that has
`use_for_related_fields = True`, and if the subclass has no explicit
manager set, we should use the class of the parent's manager.

I don't think that child class should inherit parent class's manager since
documentation says it shouldn't:
https://docs.djangoproject.com/en/dev/topics/db/managers/#custom-managers-
and-model-inheritance

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

Django

unread,
May 7, 2016, 6:15:23 PM5/7/16
to django-...@googlegroups.com
#10506: Automatically use correct auto-manager class for inherited models
-------------------------------------+-------------------------------------
Reporter: mtredinnick | Owner:
| mtredinnick
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
use_for_related_fields |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* keywords: => use_for_related_fields


--
Ticket URL: <https://code.djangoproject.com/ticket/10506#comment:7>

Django

unread,
May 16, 2016, 2:49:14 PM5/16/16
to django-...@googlegroups.com
#10506: Automatically use correct auto-manager class for inherited models
-------------------------------------+-------------------------------------
Reporter: mtredinnick | Owner:
| mtredinnick
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
use_for_related_fields |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by loic):

[https://github.com/django/django/pull/6175#issuecomment-219451336 PR6175]
revamps inheritance and allows choosing the default manager explicitly
thought the `base_manager_name` meta.

--
Ticket URL: <https://code.djangoproject.com/ticket/10506#comment:8>

Django

unread,
May 17, 2016, 1:48:30 AM5/17/16
to django-...@googlegroups.com
#10506: Automatically use correct auto-manager class for inherited models
-------------------------------------+-------------------------------------
Reporter: mtredinnick | Owner:
| mtredinnick
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
use_for_related_fields |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Loïc Bistuer <loic.bistuer@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"ed0ff913c648b16c4471fc9a9441d1ee48cb5420" ed0ff91]:
{{{
#!CommitTicketReference repository=""
revision="ed0ff913c648b16c4471fc9a9441d1ee48cb5420"
Fixed #10506, #13793, #14891, #25201 -- Introduced new APIs to specify
models' default and base managers.

This deprecates use_for_related_fields.

Old API:

class CustomManager(models.Model):
use_for_related_fields = True

class Model(models.Model):
custom_manager = CustomManager()

New API:

class Model(models.Model):
custom_manager = CustomManager()

class Meta:
base_manager_name = 'custom_manager'

Refs #20932, #25897.

Thanks Carl Meyer for the guidance throughout this work.
Thanks Tim Graham for writing the docs.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/10506#comment:9>

Reply all
Reply to author
Forward
0 new messages