summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@sixmedia.com>2014-01-22 16:53:41 +0700
committerTim Graham <timograham@gmail.com>2014-01-28 08:17:01 -0500
commit3e4dc5ecf25aa2b38eed73472899f0de5a319c04 (patch)
tree8623159df0c14a836a2207df8f475a38e6277e05
parent88a2d39159872f6a7fced1bae591550650fd7f38 (diff)
Fixed #21853 -- Fixed Manager.__module__ to properly return 'django.db.models.manager'.
The combination of BaseManager.from_queryset() and RenameMethodsBase results in Manager.__module__ having the wrong value. This can be an issue when trying to pickle the Manager class.
-rw-r--r--django/db/models/manager.py4
-rw-r--r--tests/queryset_pickle/tests.py3
2 files changed, 6 insertions, 1 deletions
diff --git a/django/db/models/manager.py b/django/db/models/manager.py
index 299faa0917..f014edcd76 100644
--- a/django/db/models/manager.py
+++ b/django/db/models/manager.py
@@ -190,7 +190,9 @@ class BaseManager(six.with_metaclass(RenameManagerMethods)):
# understanding of how this comes into play.
return self.get_queryset()
-Manager = BaseManager.from_queryset(QuerySet, class_name='Manager')
+
+class Manager(BaseManager.from_queryset(QuerySet)):
+ pass
class ManagerDescriptor(object):
diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py
index 077ac6f59c..45b75dd0e9 100644
--- a/tests/queryset_pickle/tests.py
+++ b/tests/queryset_pickle/tests.py
@@ -50,6 +50,9 @@ class PickleabilityTestCase(TestCase):
self.assertEqual(original.__class__, unpickled.__class__)
self.assertEqual(original.args, unpickled.args)
+ def test_manager_pickle(self):
+ pickle.loads(pickle.dumps(Happening.objects))
+
def test_model_pickle(self):
"""
Test that a model not defined on module level is pickleable.