Ticket #16353: sites-and-multi-db.diff
File sites-and-multi-db.diff, 1.3 KB (added by , 13 years ago) |
---|
-
django/db/backends/creation.py
252 252 # default site may or may not be 1, depending on how the sequence was 253 253 # reset. If the sites app is loaded, then we coerce it. 254 254 from django.db.models import get_model 255 from django.db import router 255 256 Site = get_model('sites', 'Site') 256 if Site is not None and Site.objects.using(self.connection.alias).count() == 1: 257 if (Site is not None 258 and router.allow_syncdb(self.connection.alias, Site) 259 and Site.objects.using(self.connection.alias).count() == 1): 257 260 Site.objects.using(self.connection.alias).update(id=settings.SITE_ID) 258 261 259 262 from django.core.cache import get_cache … … 261 264 for cache_alias in settings.CACHES: 262 265 cache = get_cache(cache_alias) 263 266 if isinstance(cache, BaseDatabaseCache): 264 from django.db import router265 267 if router.allow_syncdb(self.connection.alias, cache.cache_model_class): 266 268 call_command('createcachetable', cache._table, database=self.connection.alias) 267 269