#20257: QuerySet that prefetches related object with a ManyToMany field cannot 
be
pickled.
-------------------------------------+-------------------------------------
     Reporter:  bryced               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.5
  (models, ORM)                      |               Resolution:
     Severity:  Release blocker      |             Triage Stage:  Accepted
     Keywords:  ORM, pickle, cache   |      Needs documentation:  0
    Has patch:  0                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 The problem is that fields for automatic models (for example the
 intermediary m2m table) can't be pickled in 1.5. In master this is fixed
 by introducing Field.reduce. In 1.4 the field wasn't used directly, only
 the field.name was used so there was no problems. So, to fix this, one of
 the following three things needs to be done:
   - alter `QuerySet.__getstate__` and `__setstate__` to do something
 similar that sql.query:Query's state methods do. That is, store the
 field's name in getstate and restore back the real field instance in
 setstate.
   - remove direct storage of the field in QuerySet
   - backpatch Field.reduce changes from master

 I think the Field.reduce changes are too risky to backpatch, and I assume
 there was a good reason to store the field directly in QuerySet instead of
 field.name. So, changes to getstate and setstate seem like the best choice
 to me.

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


Reply via email to