#18272: ModelChoiceField's queryset attribute persists between two form 
instances
-------------------------------------+-------------------------------------
     Reporter:  bmispelon            |                    Owner:  Spark23
         Type:  Bug                  |                   Status:  assigned
    Component:  Forms                |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:  modelchoicefield     |             Triage Stage:
  deepcopy                           |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by ptone):

 This seems like a pretty far edge case. The internals already clear the
 cache as pointed out - specifically here:

 https://github.com/django/django/commit/ee96c7eb2d#L0R120

 while altering forms in init is a pretty common pattern, I don't think
 this would be a regularly encountered problem - though granted, I'm sure
 it would stump more than a few.

 however calling .all() to get a copy is not 'free', and clearing the cache
 is a more precise way to avoid the problem for the implementation.  I
 think that if you are going to get into this level of form override, your
 workaround is the correct way to deal with it - not to clone the queryset
 in __deepcopy__

 I'd suggest this is a candidate for "wontfix"

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18272#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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to