Skip to content
Browse files

Fixed #15573: Forced the default site id to be 1 when creating test d…

…atabases, to prevent a large number of errors when running the tests using the oracle backend.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 13bb069 commit d3c08fd8139416942da30bb22e529357e7708e2c @ikelly ikelly committed
Showing with 8 additions and 0 deletions.
  1. +8 −0 django/db/backends/
8 django/db/backends/
@@ -247,6 +247,14 @@ def create_test_db(self, verbosity=1, autoclobber=False):
verbosity=max(verbosity - 1, 0),
+ # 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

0 comments on commit d3c08fd

Please sign in to comment.
Something went wrong with that request. Please try again.