Ticket #12587: related_multiple_db.diff

File related_multiple_db.diff, 1.4 KB (added by aprilmay, 15 years ago)
  • usr/local/django-trunk/django/db/models/fields/related.py

     
    197197            return getattr(instance, self.cache_name)
    198198        except AttributeError:
    199199            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)
    201202            setattr(instance, self.cache_name, rel_obj)
    202203            return rel_obj
    203204
     
    260261            # If the related manager indicates that it should be used for
    261262            # related fields, respect that.
    262263            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
    264266            if getattr(rel_mgr, 'use_for_related_fields', False):
    265267                rel_obj = rel_mgr.using(using).get(**params)
    266268            else:
Back to Top