[Django] #25201: Allow use_for_related_fields via as_manager()

23 views
Skip to first unread message

Django

unread,
Jul 30, 2015, 9:49:06 PM7/30/15
to django-...@googlegroups.com
#25201: Allow use_for_related_fields via as_manager()
----------------------------------------------+--------------------
Reporter: litchfield | Owner: nobody
Type: New feature | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 1 | UI/UX: 0
----------------------------------------------+--------------------
The as_manager() method allows easy creation of chain-able managers. One
of the most common use cases for these is with related fields. However,
as_manager() doesn't currently allow use_for_related_fields to be
specified. This patch proposes it could be set simply by way of an
attribute on the QuerySet class, in the same way it currently does for
Manager classes.

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

Django

unread,
Aug 3, 2015, 10:10:33 PM8/3/15
to django-...@googlegroups.com
#25201: Allow use_for_related_fields via as_manager()
-------------------------------------+-------------------------------------
Reporter: litchfield | Owner:
| andersonresende
Type: New feature | Status: assigned
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by andersonresende):

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => andersonresende
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/25201#comment:1>

Django

unread,
Aug 14, 2015, 9:39:08 AM8/14/15
to django-...@googlegroups.com
#25201: Allow use_for_related_fields via as_manager()
-------------------------------------+-------------------------------------
Reporter: litchfield | Owner:
| andersonresende
Type: New feature | Status: assigned
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

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

* has_patch: 1 => 0
* easy: 1 => 0


Comment:

ticket:24863#comment:10 might solve this. By the way, if you mean to
propose a patch, I don't see it.

--
Ticket URL: <https://code.djangoproject.com/ticket/25201#comment:2>

Django

unread,
Aug 19, 2015, 3:16:34 PM8/19/15
to django-...@googlegroups.com
#25201: Allow use_for_related_fields via as_manager()
-------------------------------------+-------------------------------------
Reporter: litchfield | Owner:
| andersonresende
Type: New feature | Status: assigned
Component: Database layer | Version: 1.8
(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
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


Comment:

I think the general idea is accepted even if the exact API needs to be
worked out.

--
Ticket URL: <https://code.djangoproject.com/ticket/25201#comment:3>

Django

unread,
Apr 22, 2016, 11:07:21 AM4/22/16
to django-...@googlegroups.com
#25201: Allow use_for_related_fields via as_manager()
-------------------------------------+-------------------------------------
Reporter: litchfield | Owner:
| andersonresende
Type: New feature | Status: assigned
Component: Database layer | Version: 1.8
(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
-------------------------------------+-------------------------------------
Changes (by timgraham):

* cc: loic (added)


Comment:

Loic, can we close this in light of your PR to
[https://github.com/django/django/pull/6175 refactor manager inheritance]
(and deprecate `use_for_related_fields`)?

--
Ticket URL: <https://code.djangoproject.com/ticket/25201#comment:4>

Django

unread,
Apr 22, 2016, 3:19:45 PM4/22/16
to django-...@googlegroups.com
#25201: Allow use_for_related_fields via as_manager()
-------------------------------------+-------------------------------------
Reporter: litchfield | Owner:
| andersonresende
Type: New feature | Status: assigned
Component: Database layer | Version: 1.8
(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 loic):

Indeed, but maybe we should let the commit messages close this ticket? Not
counting the chickens before they're hatched kinda thing?

--
Ticket URL: <https://code.djangoproject.com/ticket/25201#comment:5>

Django

unread,
May 14, 2016, 6:27:49 PM5/14/16
to django-...@googlegroups.com
#25201: Allow use_for_related_fields via as_manager()
-------------------------------------+-------------------------------------
Reporter: litchfield | Owner:
| andersonresende
Type: New feature | Status: assigned
Component: Database layer | Version: 1.8
(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/25201#comment:6>

Django

unread,
May 16, 2016, 3:02:52 PM5/16/16
to django-...@googlegroups.com
#25201: Allow use_for_related_fields via as_manager()
-------------------------------------+-------------------------------------
Reporter: litchfield | Owner:
| andersonresende
Type: New feature | Status: assigned
Component: Database layer | Version: 1.8
(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]
deprecates `use_for_related_fields`.

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

Django

unread,
May 17, 2016, 1:48:30 AM5/17/16
to django-...@googlegroups.com
#25201: Allow use_for_related_fields via as_manager()
-------------------------------------+-------------------------------------
Reporter: litchfield | Owner:
| andersonresende
Type: New feature | Status: closed

Component: Database layer | Version: 1.8
(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: assigned => 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/25201#comment:8>

Reply all
Reply to author
Forward
0 new messages