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.
This commit is contained in:
Loic Bistuer 2014-01-22 16:53:41 +07:00 committed by Tim Graham
parent 88a2d39159
commit 3e4dc5ecf2
2 changed files with 6 additions and 1 deletions

View File

@ -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):

View File

@ -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.