Ticket #12587: related_multiple_db.diff
File related_multiple_db.diff, 1.4 KB (added by , 15 years ago) |
---|
-
usr/local/django-trunk/django/db/models/fields/related.py
197 197 return getattr(instance, self.cache_name) 198 198 except AttributeError: 199 199 params = {'%s__pk' % self.related.field.name: instance._get_pk_val()} 200 rel_obj = self.related.model._base_manager.using(instance._state.db).get(**params) 200 #rel_obj = self.related.model._base_manager.using(instance._state.db).get(**params) 201 rel_obj = self.related.model._base_manager.using(self.related.model._default_manager.db).get(**params) 201 202 setattr(instance, self.cache_name, rel_obj) 202 203 return rel_obj 203 204 … … 260 261 # If the related manager indicates that it should be used for 261 262 # related fields, respect that. 262 263 rel_mgr = self.field.rel.to._default_manager 263 using = instance._state.db or DEFAULT_DB_ALIAS 264 #using = instance._state.db or DEFAULT_DB_ALIAS 265 using = rel_mgr.db or DEFAULT_DB_ALIAS 264 266 if getattr(rel_mgr, 'use_for_related_fields', False): 265 267 rel_obj = rel_mgr.using(using).get(**params) 266 268 else: