Opened 9 years ago

Closed 9 years ago

#6541 closed (fixed)

wrong description of default Manager in documentation

Reported by: Thomas Capricell <django.20.orzelf@…> Owned by: nobody
Component: Documentation Version: master
Severity: Keywords: Manager Model
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


On it is written
"If you use custom Manager objects, take note that the first Manager Django encounters (in order by which they’re defined in the model) has a special status. Django interprets the first Manager defined in a class as the “default” Manager. Certain operations — such as Django’s admin site — use the default Manager to obtain lists of objects, so it’s generally a good idea for the first Manager to be relatively unfiltered."

It doesn't work here, and it seems the code has changed in trunk with respect to this.
On irc i've been told to do "manager =" in class Admin, and indeed it works. They also asked me to report it here :-)

Change History (3)

comment:1 Changed 9 years ago by Malcolm Tredinnick

"it doesn't work" is not really specific enough to work on this problem. What exactly are you doing and what doesn't work? That is, please give us some steps to duplicate the problem. A small example (a model with one field, say), would be ideal.

comment:2 Changed 9 years ago by Thomas Capricell <django.20.orzelf@…>

(Sorry, i was in a hurry)

With the following code, the admin interface will not use MoniteurManager, but the usual, unfiltered, default one.

class MoniteurManager(models.Manager):

def get_query_set(self):

raise ValueError
return super(MoniteurManager,self).get_query_set().filter(anneein=[1,2,3])

class Moniteur(models.Model):

objects_current = MoniteurManager()
annee = models.IntegerField("Année", choices=ANNEE_CHOICES, default='1', core=True)
class Admin:


It works if i do :

class Moniteur(models.Model):

class Admin:

manager = MoniteurManager()

comment:3 Changed 9 years ago by James Bennett

Resolution: fixed
Status: newclosed

(In [7302]) Fixed #6541: Corrected documentation of how the admin chooses a default manager. Refs #6538.

Note: See TracTickets for help on using tickets.
Back to Top