From 80547335c03f8d7a0867cc7d7a55e373555c320a Mon Sep 17 00:00:00 2001 From: Patryk Zawadzki Date: Mon, 20 Jan 2014 12:50:37 +0100 Subject: [PATCH] Don't try to access __slots__ during copy() When subclassing Django will copy managers from the ancestor class. Copying in turn calls `copy.copy()` which checks whether the object uses `__slots__` or `__dict__`. This could result in the manager calling `self.get_queryset()` before all models get registered with the ORM. --- model_utils/managers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/model_utils/managers.py b/model_utils/managers.py index 2785d2f..71a4dc1 100644 --- a/model_utils/managers.py +++ b/model_utils/managers.py @@ -225,7 +225,8 @@ class PassThroughManagerMixin(object): # pickling causes recursion errors _deny_methods = ['__getstate__', '__setstate__', '__getinitargs__', - '__getnewargs__', '__copy__', '__deepcopy__', '_db'] + '__getnewargs__', '__copy__', '__deepcopy__', '_db', + '__slots__'] def __init__(self, queryset_cls=None): self._queryset_cls = queryset_cls