Loading django/db/models/fields/related.py +5 −0 Original line number Diff line number Diff line Loading @@ -1407,6 +1407,11 @@ class ManyToOneRel(ForeignObjectRel): parent_link=parent_link, on_delete=on_delete, related_query_name=related_query_name) self.field_name = field_name def __getstate__(self): state = self.__dict__.copy() state.pop('related_model', None) return state def get_related_field(self): """ Returns the Field in the 'to' object to which this relationship is Loading docs/releases/1.8.3.txt +3 −0 Original line number Diff line number Diff line Loading @@ -37,3 +37,6 @@ Bugfixes * Fixed lack of unique constraint when changing a field from ``primary_key=True`` to ``unique=True`` (:ticket:`24893`). * Fixed queryset pickling when using ``prefetch_related()`` after deleting objects (:ticket:`24831`). tests/queryset_pickle/tests.py +14 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,20 @@ class PickleabilityTestCase(TestCase): groups = pickle.loads(pickle.dumps(groups)) self.assertQuerysetEqual(groups, [g], lambda x: x) def test_pickle_prefetch_related_with_m2m_and_objects_deletion(self): """ #24831 -- Cached properties on ManyToOneRel created in QuerySet.delete() caused subsequent QuerySet pickling to fail. """ g = Group.objects.create(name='foo') m2m = M2MModel.objects.create() m2m.groups.add(g) Group.objects.all().delete() m2ms = M2MModel.objects.prefetch_related('groups') m2ms = pickle.loads(pickle.dumps(m2ms)) self.assertQuerysetEqual(m2ms, [m2m], lambda x: x) def test_missing_django_version_unpickling(self): """ #21430 -- Verifies a warning is raised for querysets that are Loading Loading
django/db/models/fields/related.py +5 −0 Original line number Diff line number Diff line Loading @@ -1407,6 +1407,11 @@ class ManyToOneRel(ForeignObjectRel): parent_link=parent_link, on_delete=on_delete, related_query_name=related_query_name) self.field_name = field_name def __getstate__(self): state = self.__dict__.copy() state.pop('related_model', None) return state def get_related_field(self): """ Returns the Field in the 'to' object to which this relationship is Loading
docs/releases/1.8.3.txt +3 −0 Original line number Diff line number Diff line Loading @@ -37,3 +37,6 @@ Bugfixes * Fixed lack of unique constraint when changing a field from ``primary_key=True`` to ``unique=True`` (:ticket:`24893`). * Fixed queryset pickling when using ``prefetch_related()`` after deleting objects (:ticket:`24831`).
tests/queryset_pickle/tests.py +14 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,20 @@ class PickleabilityTestCase(TestCase): groups = pickle.loads(pickle.dumps(groups)) self.assertQuerysetEqual(groups, [g], lambda x: x) def test_pickle_prefetch_related_with_m2m_and_objects_deletion(self): """ #24831 -- Cached properties on ManyToOneRel created in QuerySet.delete() caused subsequent QuerySet pickling to fail. """ g = Group.objects.create(name='foo') m2m = M2MModel.objects.create() m2m.groups.add(g) Group.objects.all().delete() m2ms = M2MModel.objects.prefetch_related('groups') m2ms = pickle.loads(pickle.dumps(m2ms)) self.assertQuerysetEqual(m2ms, [m2m], lambda x: x) def test_missing_django_version_unpickling(self): """ #21430 -- Verifies a warning is raised for querysets that are Loading