Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#11853 closed (invalid)

Django admin uses default Manager

Reported by: Alasdair <alasdair@…> Owned by: nobody
Component: Uncategorized Version: 1.1
Severity: Keywords: admin Managers
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I've defined a custom manager for my Entry model:

Class Entry(models.Model):
    [snip...]
    live = LiveEntryManager()
    objects = models.Manager()

The documentation says:

"Django interprets this first Manager defined in a class as the "default" Manager, and several parts of Django (though not the admin application) will use that Manager exclusively for that model."

which I understand to mean that the admin will continue to use models.Manager. However the admin appears to use the LiveEntryManager. It is not clear how I can get the admin application to use models.Manager, and display all Entries.

Apologies if I've misunderstood the documentation.

Attachments (0)

Change History (2)

comment:1 follow-up: Changed 5 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

The docs are correct; LiveEntryManager is the "first Manager defined in [the] class", and so the admin uses it to access entries for that model. Look into the queryset argument to ModelAdmin to change what queryset the admin uses.

comment:2 in reply to: ↑ 1 Changed 5 years ago by kmtracey

Replying to jacob:

The docs are correct; LiveEntryManager is the "first Manager defined in [the] class", and so the admin uses it to access entries for that model. Look into the queryset argument to ModelAdmin to change what queryset the admin uses.

Except the parenthetical comment in the docs state the admin will NOT use the default manager exclusively. If I didn't know about setting queryset for a ModelAdmin (which doesn't seem to be documented?) I would have interpreted that parenthetical aside the same way the reporter did. That sentence is very confusing.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.