#33208: Allow globally defining custom (i.e. with select_related) querysets for
ModelChoiceFields/ForeignKeys
-----------------------------------+--------------------------------------
     Reporter:  Matthijs Kooijman  |                    Owner:  nobody
         Type:  New feature        |                   Status:  closed
    Component:  contrib.admin      |                  Version:  3.2
     Severity:  Normal             |               Resolution:  wontfix
     Keywords:                     |             Triage Stage:  Unreviewed
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+--------------------------------------

Comment (by Matthijs Kooijman):

 Thanks for your responses.

 >  Thanks for the report, however I don't think a new hook is necessary
 you can use ​ModelAdmin.autocomplete_fields to avoid selecting all related
 instances to display in the dropdown, as documented:

 I would not really consider that a solution of this particular problem. It
 significantly changes UI (which might not be what I want here) which
 prevents this prefetching from being needed, but IMHO does not really
 solve the problem itself. But yeah, it does prevent the problem from being
 a problem, that's true :-)

 > Also, there are both ​established ways of optimising this and
 ​customising choice generation (but these are topics for ​the Using
 category on the Forum rather than here 🙂)

 AFAICS those all work on the form end of things, which would be similar to
 (maybe even more verbose than) the `formfield_for_foreignkey()`-based
 approach I suggested above. However, the point of this ticket was to talk
 about solving this more centrally on the original model side of things.

 Having said that, I can see that fixing this is not easy and can be
 considered out of scope, so closing as wontfix is perfectly acceptable.
 Also, thanks for the links, I've learned a few new things from them :-)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33208#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/074.8927eace4114e945b622a8c549161436%40djangoproject.com.

Reply via email to