#13192 closed (duplicate)
ModelAdmin.queryset() internal documentation
Reported by: | 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.
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:
in which case, this ticket doesn't require any additional activity.