Ticket #16353: 16353.diff

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

     
    248248            interactive=False,
    249249            database=self.connection.alias)
    250250
    251         # One effect of calling syncdb followed by flush is that the id of the
    252         # default site may or may not be 1, depending on how the sequence was
    253         # reset.  If the sites app is loaded, then we coerce it.
    254         from django.db.models import get_model
    255         Site = get_model('sites', 'Site')
    256         if Site is not None and Site.objects.using(self.connection.alias).count() == 1:
    257             Site.objects.using(self.connection.alias).update(id=settings.SITE_ID)
    258 
    259251        from django.core.cache import get_cache
    260252        from django.core.cache.backends.db import BaseDatabaseCache
    261253        for cache_alias in settings.CACHES:
  • django/contrib/gis/db/backends/spatialite/creation.py

     
    5656            interactive=False,
    5757            database=self.connection.alias)
    5858
    59         # One effect of calling syncdb followed by flush is that the id of the
    60         # default site may or may not be 1, depending on how the sequence was
    61         # reset.  If the sites app is loaded, then we coerce it.
    62         from django.db.models import get_model
    63         Site = get_model('sites', 'Site')
    64         if Site is not None and Site.objects.using(self.connection.alias).count() == 1:
    65             Site.objects.using(self.connection.alias).update(id=settings.SITE_ID)
    66 
    6759        from django.core.cache import get_cache
    6860        from django.core.cache.backends.db import BaseDatabaseCache
    6961        for cache_alias in settings.CACHES:
  • django/contrib/sites/management.py

     
    33"""
    44
    55from django.db.models import signals
     6from django.db import router
    67from django.contrib.sites.models import Site
    78from django.contrib.sites import models as site_app
    89
    910def create_default_site(app, created_models, verbosity, db, **kwargs):
    10     if Site in created_models:
     11    # Only create the default sites in databases where Django created the table
     12    if Site in created_models and router.allow_syncdb(db, Site) :
    1113        if verbosity >= 2:
    1214            print "Creating example.com Site object"
    13         s = Site(domain="example.com", name="example.com")
     15        # Django's test suite sets settings.SITE_ID = 1, and several tests
     16        # rely on this value. However, during the creation of the databases
     17        # for the tests, syncdb is called followed by flush. Depending on
     18        # how the autoincrementing sequences are reset, it isn't guaranteed
     19        # that the next id will be 1, so we coerce it. See #15573 and #16353.
     20        s = Site(pk=1, domain="example.com", name="example.com")
    1421        s.save(using=db)
    1522    Site.objects.clear_cache()
    1623
Back to Top