Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#13192 closed (duplicate)

ModelAdmin.queryset() internal documentation

Reported by: Keryn Knight <kez.knight@…> Owned by: nobody
Component: contrib.admin Version: 1.1
Severity: Keywords: queryset modeladmin documentation
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Part of this may tie into #10712 which is an attempt to provide userland documentation for ModelAdmin methods. Currently, the internal docstring for ModelAdmin.queryset() reads as follows:

"""
Returns a QuerySet of all model instances that can be edited by the
admin site. This is used by changelist_view.
 """

The implication seems to be that its only called by the changelist. In certain circumstances, it may be useful to override what's displayed in the changelist - this is part of what #10712 attempts to address. Modifying the queryset method (and by extension ChangeList) actually affects the queryset used by the entire modeladmin, which means one cannot navigate to an edit object not in the modified queryset.

I concede that this is currently by design, and is in most cases the expected (and desired) behaviour. Certain circumstances may facilitate changing this default, which currently involves generating two ChangeList objects in the changelist_view() method and using context precedence to get rid of the original.

As I see it, there are three options. The simplest is obviously to ignore this as by design and wontfix. Another is to expand the docstring to explain in more detail its overall role in the modeladmin (which may mean changing #10712 further). The hardest (and best, in my opinion) option is, I think, mostly put forward by #10761 - have multiple methods we can easily modify in userland, defaulting back to queryset() if they're not provided, perhaps.

Change History (2)

comment:1 by Russell Keith-Magee, 15 years ago

Resolution: duplicate
Status: newclosed

I'm going to close this as a duplciate of #10712 and #10761; the call for action in the last paragraph seems to summarize that the options are:

  1. Do nothing
  2. Fix #10712
  3. Fix #10761

in which case, this ticket doesn't require any additional activity.

comment:2 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

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