diff --git a/django/contrib/contenttypes/generic.py b/django/contrib/contenttypes/generic.py
index 5690e6b..425c63a 100644
a
|
b
|
class GenericForeignKey(object):
|
55 | 55 | # using this model |
56 | 56 | ContentType = get_model("contenttypes", "contenttype") |
57 | 57 | if obj: |
58 | | return ContentType.objects.db_manager(obj._state.db).get_for_model(obj) |
| 58 | return ContentType.objects.db_manager(ContentType.objects.db).get_for_model(obj) |
59 | 59 | elif id: |
60 | 60 | return ContentType.objects.db_manager(using).get_for_id(id) |
61 | 61 | else: |
diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py
index b658655..92e8324 100644
a
|
b
|
|
1 | 1 | from django.db import models |
| 2 | from django.db import router, DEFAULT_DB_ALIAS |
2 | 3 | from django.utils.translation import ugettext_lazy as _ |
3 | 4 | from django.utils.encoding import smart_text, force_text |
4 | 5 | from django.utils.encoding import python_2_unicode_compatible |
… |
… |
class ContentType(models.Model):
|
164 | 165 | method. The ObjectNotExist exception, if thrown, will not be caught, |
165 | 166 | so code that calls this method should catch it. |
166 | 167 | """ |
167 | | return self.model_class()._base_manager.using(self._state.db).get(**kwargs) |
| 168 | return self.model_class()._base_manager.using(router.db_for_read(self.model_class()) or DEFAULT_DB_ALIAS).get(**kwargs) |
168 | 169 | |
169 | 170 | def get_all_objects_for_this_type(self, **kwargs): |
170 | 171 | """ |