Ticket #15610: django-1.6.5-15610.patch
File django-1.6.5-15610.patch, 1.9 KB (added by , 10 years ago) |
---|
-
django/contrib/contenttypes/generic.py
a b 65 65 66 66 def get_content_type(self, obj=None, id=None, using=None): 67 67 if obj is not None: 68 return ContentType.objects.db_manager(obj._state.db).get_for_model( 68 return ContentType.objects.db_manager( 69 ContentType.objects.db).get_for_model( 69 70 obj, for_concrete_model=self.for_concrete_model) 70 71 elif id: 71 72 return ContentType.objects.db_manager(using).get_for_id(id) -
django/contrib/contenttypes/models.py
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 … … 165 166 method. The ObjectNotExist exception, if thrown, will not be caught, 166 167 so code that calls this method should catch it. 167 168 """ 168 return self.model_class()._base_manager.using(self._state.db).get(**kwargs) 169 return self.model_class()._base_manager.using( 170 router.db_for_read(self.model_class()) or DEFAULT_DB_ALIAS 171 ).get(**kwargs) 169 172 170 173 def get_all_objects_for_this_type(self, **kwargs): 171 174 """ 172 175 Returns all objects of this type for the keyword arguments given. 173 176 """ 174 return self.model_class()._base_manager.using(self._state.db).filter(**kwargs) 177 return self.model_class()._base_manager.using( 178 router.db_for_read(self.model_class()) or DEFAULT_DB_ALIAS 179 ).filter(**kwargs) 175 180 176 181 def natural_key(self): 177 182 return (self.app_label, self.model)