#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 <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.7547aa6284a4355436dfb26327881f0e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.