Django

Code

Ticket #6541 (closed: fixed)

Opened 7 months ago

Last modified 6 months ago

wrong description of default Manager in documentation

Reported by: Thomas Capricell <django.20.orzelf@spamgourmet.com> Assigned to: nobody
Milestone: Component: Documentation
Version: SVN Keywords: Manager Model
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

On http://www.djangoproject.com/documentation/model-api/#modifying-initial-manager-querysets 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 :-)

Attachments

Change History

02/03/08 19:46:45 changed by mtredinnick

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

"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.

02/04/08 00:56:28 changed by Thomas Capricell <django.20.orzelf@spamgourmet.com>

(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:

etc....

It works if i do :

class Moniteur(models.Model):

class Admin:

manager = MoniteurManager?()

03/18/08 14:55:21 changed by ubernostrum

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #6541 (wrong description of default Manager in documentation)




Change Properties
Action