[Django] #24911: QuerySet is initiated with model=None as kwarg, but is called in BaseManager.get_queryset() as arg.

12 views
Skip to first unread message

Django

unread,
Jun 3, 2015, 7:11:58 PM6/3/15
to django-...@googlegroups.com
#24911: QuerySet is initiated with model=None as kwarg, but is called in
BaseManager.get_queryset() as arg.
----------------------------------------------+--------------------
Reporter: 317070 | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
----------------------------------------------+--------------------
QuerySet is initiated with model=None as named argument a.k.a. kwarg:
{{{
class QuerySet(object):
def __init__(self, model=None, query=None, using=None, hints=None):
}}}
But it is called in get_queryset as positional argument a.k.a. arg:
{{{
def get_queryset(self):
return self._queryset_class(self.model, using=self._db,
hints=self._hints)
}}}
This causes trouble when overriding get_queryset (which is the idea behind
the method) and using super(BlaBlaManager, self).get_queryset() which
returns a non-standard queryset-class, where model is not necessarily the
first argument, which should have been okay as model is a named argument.

Proposed solution:
in db/models/manager.py
{{{
def get_queryset(self):
return self._queryset_class(model=self.model, using=self._db,
hints=self._hints)
}}}

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

Django

unread,
Jun 3, 2015, 7:19:43 PM6/3/15
to django-...@googlegroups.com
#24911: QuerySet is initiated with model=None as kwarg, but is called in
BaseManager.get_queryset() as arg.
-------------------------------------+-------------------------------------

Reporter: 317070 | Owner: nobody
Type: Bug | Status: new
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by 317070):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Old description:

> QuerySet is initiated with model=None as named argument a.k.a. kwarg:
> {{{
> class QuerySet(object):
> def __init__(self, model=None, query=None, using=None, hints=None):
> }}}
> But it is called in get_queryset as positional argument a.k.a. arg:
> {{{
> def get_queryset(self):
> return self._queryset_class(self.model, using=self._db,
> hints=self._hints)
> }}}
> This causes trouble when overriding get_queryset (which is the idea
> behind the method) and using super(BlaBlaManager, self).get_queryset()
> which returns a non-standard queryset-class, where model is not
> necessarily the first argument, which should have been okay as model is a
> named argument.
>
> Proposed solution:
> in db/models/manager.py
> {{{
> def get_queryset(self):
> return self._queryset_class(model=self.model, using=self._db,
> hints=self._hints)
> }}}

New description:

QuerySet is initiated with {{{model=None}}} as named argument a.k.a.
kwarg:
{{{
class QuerySet(object):
def __init__(self, model=None, query=None, using=None, hints=None):
}}}

But it is called in {{{get_queryset()}}} as positional argument a.k.a.


arg:
{{{
def get_queryset(self):
return self._queryset_class(self.model, using=self._db,
hints=self._hints)
}}}
This causes trouble when overriding {{{get_queryset}}} (which is the idea
behind the method) and using {{{super(BlaBlaManager,
self).get_queryset()}}} which returns a non-standard queryset-class, where
model is not necessarily the first argument, which should have been okay
as model is a named argument.

Proposed solution:
in db/models/manager.py
{{{
def get_queryset(self):
return self._queryset_class(model=self.model, using=self._db,
hints=self._hints)
}}}

Github pull request: https://github.com/django/django/pull/4745

--

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

Django

unread,
Jun 3, 2015, 7:37:21 PM6/3/15
to django-...@googlegroups.com
#24911: QuerySet is initiated with model=None as kwarg, but is called in
BaseManager.get_queryset() as arg.
-------------------------------------+-------------------------------------

Reporter: 317070 | Owner: nobody
Type: Bug | Status: new
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 317070):

* has_patch: 0 => 1


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

Django

unread,
Jun 4, 2015, 9:18:28 PM6/4/15
to django-...@googlegroups.com
#24911: QuerySet is initiated with model=None as kwarg, but is called in
BaseManager.get_queryset() as arg.
-------------------------------------+-------------------------------------

Reporter: 317070 | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

* needs_tests: 0 => 1
* stage: Unreviewed => Accepted


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

Django

unread,
Jun 5, 2015, 12:38:18 PM6/5/15
to django-...@googlegroups.com
#24911: QuerySet is initiated with model=None as kwarg, but is called in
BaseManager.get_queryset() as arg.
-------------------------------------+-------------------------------------
Reporter: 317070 | Owner: 317070
Type: Bug | Status: assigned

Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* owner: nobody => 317070
* status: new => assigned
* needs_tests: 1 => 0


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

Django

unread,
Jun 5, 2015, 5:15:55 PM6/5/15
to django-...@googlegroups.com
#24911: QuerySet is initiated with model=None as kwarg, but is called in
BaseManager.get_queryset() as arg.
-------------------------------------+-------------------------------------
Reporter: 317070 | Owner: 317070
Type: Bug | Status: closed

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

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


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

Django

unread,
Jun 5, 2015, 5:19:03 PM6/5/15
to django-...@googlegroups.com
#24911: QuerySet is initiated with model=None as kwarg, but is called in
BaseManager.get_queryset() as arg.
-------------------------------------+-------------------------------------
Reporter: 317070 | Owner: 317070
Type: Bug | Status: new

Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


--
Ticket URL: <https://code.djangoproject.com/ticket/24911#comment:6>

Django

unread,
Jun 30, 2015, 1:57:11 PM6/30/15
to django-...@googlegroups.com
#24911: QuerySet is initiated with model=None as kwarg, but is called in
BaseManager.get_queryset() as arg.
-------------------------------------+-------------------------------------
Reporter: 317070 | Owner: 317070
Type: Bug | Status: closed

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

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"4352e865a75923a0e5036b4e9ba2a8f0bfae3d63" 4352e865]:
{{{
#!CommitTicketReference repository=""
revision="4352e865a75923a0e5036b4e9ba2a8f0bfae3d63"
Fixed #24911 -- Made BaseManager.get_queryset() allow custom queryset
args.
}}}

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

Reply all
Reply to author
Forward
0 new messages