Last active
August 29, 2015 14:20
-
-
Save amirouche/dfead671ee88b16c3a28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/django/db/models/manager.py b/django/db/models/manager.py | |
index b607900..c7efd49 100644 | |
--- a/django/db/models/manager.py | |
+++ b/django/db/models/manager.py | |
@@ -179,7 +179,14 @@ class BaseManager(six.with_metaclass(RenameManagerMethods)): | |
Returns a new QuerySet object. Subclasses can override this method to | |
easily customize the behavior of the Manager. | |
""" | |
- return self._queryset_class(self.model, using=self._db, hints=self._hints) | |
+ queryset = self._queryset_class(self.model, using=self._db, hints=self._hints) | |
+ try: | |
+ db = self.model.meta.db | |
+ except AttributeError: | |
+ return queryset | |
+ else: | |
+ queryset.using(db) | |
+ return queryset | |
def all(self): | |
# We can't proxy this method through the `QuerySet` like we do for the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment