Opened 10 years ago
Closed 10 years ago
#24911 closed Bug (fixed)
QuerySet is initiated with model=None as kwarg, but is called in BaseManager.get_queryset() as arg.
| Reported by: | Jonas Degrave | Owned by: | Jonas Degrave | 
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.8 | 
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | yes | UI/UX: | no | 
Description (last modified by )
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
Change History (7)
comment:1 by , 10 years ago
| Description: | modified (diff) | 
|---|
comment:2 by , 10 years ago
| Has patch: | set | 
|---|
comment:3 by , 10 years ago
| Needs tests: | set | 
|---|---|
| Triage Stage: | Unreviewed → Accepted | 
comment:4 by , 10 years ago
| Needs tests: | unset | 
|---|---|
| Owner: | changed from to | 
| Status: | new → assigned | 
comment:5 by , 10 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | assigned → closed | 
comment:6 by , 10 years ago
| Resolution: | fixed | 
|---|---|
| Status: | closed → new | 
comment:7 by , 10 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
In 4352e865: