Combined with the fact that there's no documented way to clear that
(#16856), it's quite undesirable behaviour.
In my opinion this could be resolved in 2 ways:
1. Remove that .select_related() call altogether and let the developer
choose the exact optimization if he is displaying related fields in the
listing
2. Optimize the select_related() call so that it's constructed exactly
based on which fields appear in `list_display`
--
Ticket URL: <https://code.djangoproject.com/ticket/19080>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Have you tried setting the `ModelAdmin.list_select_related` to `False`?
Does it solve your problem?
--
Ticket URL: <https://code.djangoproject.com/ticket/19080#comment:1>
* stage: Unreviewed => Accepted
Comment:
Oh wait, never mind. The `list_select_related` attribute would in fact be
ignored in your case.
I think your suggestion "2." would be too complex to implement and could
be quite brittle.
I think "1." seems reasonable — it all depends if in most cases the
developer would want to use select_related or not. It'd be good to provide
a sane default that can be occasionally overridden. It'd be good to gather
some anecdotal statistics on that. If it appears that using
`select_related` would in fact be a sane default, then I'd rather focus on
enabling the clearing of the `select_related` behavior (as discussed in
#16856) for the time being.
Accepting this ticket on the basis that this is a valid issue that needs
fixing.
--
Ticket URL: <https://code.djangoproject.com/ticket/19080#comment:2>
Comment (by oinopion):
I've added pull request for this ticket:
https://github.com/django/django/pull/1245
It implements finer control over select_related, allowing setting this
attribute to a tuple. Empty tuple disables select related and any other is
passed as arguments to select_related.
--
Ticket URL: <https://code.djangoproject.com/ticket/19080#comment:3>
* cc: tomek@… (added)
* owner: bberes => oinopion
* has_patch: 0 => 1
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/19080#comment:4>
Comment (by Marc Tamlyn <marc.tamlyn@…>):
In [changeset:"9ed971f4f1d2f05ecf7e2760556259eb2dca85f8"]:
{{{
#!CommitTicketReference repository=""
revision="9ed971f4f1d2f05ecf7e2760556259eb2dca85f8"
Merge pull request #1245 from oinopion/list_select_related
Fixed #19080 -- Fine-grained control over select_related in admin
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/19080#comment:6>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"0fd9f7c95f748764867dc148a2bacef807466d85"]:
{{{
#!CommitTicketReference repository=""
revision="0fd9f7c95f748764867dc148a2bacef807466d85"
Fixed #19080 -- Fine-grained control over select_related in admin
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/19080#comment:5>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"158eca4f93e492a6cc6f0240a0b6da3b7aa98ee6" 158eca4f]:
{{{
#!CommitTicketReference repository=""
revision="158eca4f93e492a6cc6f0240a0b6da3b7aa98ee6"
Refs #19080 -- Added tests for preserving select_related() in the admin
changelist.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/19080#comment:7>