Ticket #16828: 16828.diff

File 16828.diff, 1.5 KB (added by Aymeric Augustin, 13 years ago)
  • django/db/backends/creation.py

    old new  
    374374            verbosity=max(verbosity - 1, 0),
    375375            interactive=False,
    376376            database=self.connection.alias)
    377        
     377
    378378        # One effect of calling syncdb followed by flush is that the id of the
    379379        # default site may or may not be 1, depending on how the sequence was
    380380        # reset.  If the sites app is loaded, then we coerce it.
    381381        from django.db.models import get_model
     382        from django.db import router
    382383        if 'django.contrib.sites' in settings.INSTALLED_APPS:
    383384            Site = get_model('sites', 'Site')
    384             if Site is not None and Site.objects.using(self.connection.alias).count() == 1:
     385            if (Site is not None
     386                and router.allow_syncdb(self.connection.alias, Site)
     387                and Site.objects.using(self.connection.alias).count() == 1):
    385388                Site.objects.using(self.connection.alias).update(id=settings.SITE_ID)
    386389
    387390        from django.core.cache import get_cache
     
    389392        for cache_alias in settings.CACHES:
    390393            cache = get_cache(cache_alias)
    391394            if isinstance(cache, BaseDatabaseCache):
    392                 from django.db import router
    393395                if router.allow_syncdb(self.connection.alias, cache.cache_model_class):
    394396                    call_command('createcachetable', cache._table, database=self.connection.alias)
    395397
Back to Top