#20257: QuerySet that prefetches related object with a ManyToMany field cannot 
be
pickled.
-------------------------------------+--------------------------------
     Reporter:  bryced               |      Owner:  nobody
         Type:  Bug                  |     Status:  new
    Component:  Core (Cache system)  |    Version:  1.5
     Severity:  Release blocker      |   Keywords:  ORM, pickle, cache
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  0                    |      UI/UX:  0
-------------------------------------+--------------------------------
 After upgrading from 1.4 to 1.5, exceptions were thrown when trying to
 pickle certain querysets. This means that the caching framework doesn't
 work for these querysets.

 In 1.4 the following code runs fine. In 1.5 this error occurs:
 {{{
 PicklingError: Can't pickle <class 'people.models.SocialProfile_friends'>:
 it's not found as people.models.SocialProfile_friends
 }}}


 models.py
 {{{
 from django.db import models


 class Person(models.Model):
     name = models.CharField(max_length=200)


 class SocialProfile(models.Model):
     person = models.ForeignKey(Person)
     friends = models.ManyToManyField('self')

 }}}

 tests.py
 {{{
 from django.test import TestCase
 from people.models import Person
 import pickle


 class SimpleTest(TestCase):

     def test_pickle_failure(self):
         bob = Person(name="Bob")
         bob.save()

         people =
 Person.objects.all().prefetch_related('socialprofile_set')
         pickle.dumps(people)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20257>
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].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to