#23623: ModelChoiceField generates unused temporary cache
-------------------------------------+-------------------------------------
     Reporter:  tchaumeny            |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |                  Version:  master
    Component:  Forms                |               Resolution:
     Severity:  Normal               |             Triage Stage:
     Keywords:  ModelChoiceField,    |  Unreviewed
  admin                              |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by tchaumeny):

 I missed that ticket, thanks. My understanding of #22841 is that it
 proposes a way to "tell" the `ModelChoiceField` to reuse a `queryset`
 instead of reevaluating it at each time.

 I think that my PR is related but compatible with that proposed change as
 it handles the case where we don't want to reuse the `queryset`. That case
 is currently handled by iterating on `queryset.all()` — which creates a
 cloned unevaluated queryset — to construct the choices. My proposition is
 to use `iterator()` instead as this is designed precisely for those cases
 where you don't want to use cache nor to populate it.

--
Ticket URL: <https://code.djangoproject.com/ticket/23623#comment:4>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.7ea47b7bb53a66e5750781ad050cbd97%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to