Index: django/db/backends/creation.py
===================================================================
--- django/db/backends/creation.py	(révision 16855)
+++ django/db/backends/creation.py	(copie de travail)
@@ -248,14 +248,6 @@
             interactive=False,
             database=self.connection.alias)
 
-        # One effect of calling syncdb followed by flush is that the id of the
-        # default site may or may not be 1, depending on how the sequence was
-        # reset.  If the sites app is loaded, then we coerce it.
-        from django.db.models import get_model
-        Site = get_model('sites', 'Site')
-        if Site is not None and Site.objects.using(self.connection.alias).count() == 1:
-            Site.objects.using(self.connection.alias).update(id=settings.SITE_ID)
-
         from django.core.cache import get_cache
         from django.core.cache.backends.db import BaseDatabaseCache
         for cache_alias in settings.CACHES:
Index: django/contrib/gis/db/backends/spatialite/creation.py
===================================================================
--- django/contrib/gis/db/backends/spatialite/creation.py	(révision 16855)
+++ django/contrib/gis/db/backends/spatialite/creation.py	(copie de travail)
@@ -56,14 +56,6 @@
             interactive=False,
             database=self.connection.alias)
 
-        # One effect of calling syncdb followed by flush is that the id of the
-        # default site may or may not be 1, depending on how the sequence was
-        # reset.  If the sites app is loaded, then we coerce it.
-        from django.db.models import get_model
-        Site = get_model('sites', 'Site')
-        if Site is not None and Site.objects.using(self.connection.alias).count() == 1:
-            Site.objects.using(self.connection.alias).update(id=settings.SITE_ID)
-
         from django.core.cache import get_cache
         from django.core.cache.backends.db import BaseDatabaseCache
         for cache_alias in settings.CACHES:
Index: django/contrib/sites/management.py
===================================================================
--- django/contrib/sites/management.py	(révision 16855)
+++ django/contrib/sites/management.py	(copie de travail)
@@ -3,14 +3,21 @@
 """
 
 from django.db.models import signals
+from django.db import router
 from django.contrib.sites.models import Site
 from django.contrib.sites import models as site_app
 
 def create_default_site(app, created_models, verbosity, db, **kwargs):
-    if Site in created_models:
+    # Only create the default sites in databases where Django created the table
+    if Site in created_models and router.allow_syncdb(db, Site) :
         if verbosity >= 2:
             print "Creating example.com Site object"
-        s = Site(domain="example.com", name="example.com")
+        # Django's test suite sets settings.SITE_ID = 1, and several tests
+        # rely on this value. However, during the creation of the databases
+        # for the tests, syncdb is called followed by flush. Depending on
+        # how the autoincrementing sequences are reset, it isn't guaranteed
+        # that the next id will be 1, so we coerce it. See #15573 and #16353.
+        s = Site(pk=1, domain="example.com", name="example.com")
         s.save(using=db)
     Site.objects.clear_cache()
 
