Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 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: UI/UX:

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.

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by russellm

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

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 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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.