Ticket #16353: sites-and-multi-db.diff

File sites-and-multi-db.diff, 1.3 KB (added by aaugustin, 4 years ago)
  • django/db/backends/creation.py

     
    252252        # default site may or may not be 1, depending on how the sequence was
    253253        # reset.  If the sites app is loaded, then we coerce it.
    254254        from django.db.models import get_model
     255        from django.db import router
    255256        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):
    257260            Site.objects.using(self.connection.alias).update(id=settings.SITE_ID)
    258261
    259262        from django.core.cache import get_cache
     
    261264        for cache_alias in settings.CACHES:
    262265            cache = get_cache(cache_alias)
    263266            if isinstance(cache, BaseDatabaseCache):
    264                 from django.db import router
    265267                if router.allow_syncdb(self.connection.alias, cache.cache_model_class):
    266268                    call_command('createcachetable', cache._table, database=self.connection.alias)
    267269
Back to Top