Opened 9 years ago

Last modified 9 years ago

#24911 closed Bug

QuerySet is initiated with model=None as kwarg, but is called in BaseManager.get_queryset() as arg. — at Version 1

Reported by: Jonas Degrave Owned by: nobody
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 Jonas Degrave)

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 (1)

comment:1 by Jonas Degrave, 9 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top