Commits

Paul McLanahan committed 6d80c54

Fixed a recursion error in Django 1.1

Comments (0)

Files changed (2)

model_utils/managers.py

         objects = PassThroughManager(PostQuerySet)
     '''
     # pickling causes recursion errors
-    _deny_methods = ['__getstate__', '__setstate__']
+    _deny_methods = ['__getstate__', '__setstate__', '_db']
     
     def __init__(self, queryset_cls=None):
         self._queryset_cls = queryset_cls
     
     def get_query_set(self):
         if self._queryset_cls is not None:
-            return self._queryset_cls(self.model, using=self._db)
+            kargs = {'model': self.model}
+            if hasattr(self, '_db'):
+                kargs['using'] = self._db
+            return self._queryset_cls(**kargs)
         return super(PassThroughManager, self).get_query_set()
 
 

model_utils/tests/models.py

 
 class AbidingManager(PassThroughManager):
     def get_query_set(self):
-        return DudeQuerySet(self.model, using=self._db).abiding()
+        return DudeQuerySet(self.model).abiding()
     
     def get_stats(self):
         return {