summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Kelly <ian.g.kelly@gmail.com>2011-04-15 21:49:22 +0000
committerIan Kelly <ian.g.kelly@gmail.com>2011-04-15 21:49:22 +0000
commitd3c08fd8139416942da30bb22e529357e7708e2c (patch)
tree5305e98c71f91541fb9e9c9ec75bdac3e6da2fa5
parent13bb06984cdfb937d0eac13b78c7c2337442c561 (diff)
Fixed #15573: Forced the default site id to be 1 when creating test databases, to prevent a large number of errors when running the tests using the oracle backend.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16027 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/backends/creation.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py
index 9b11a63341..437a4297af 100644
--- a/django/db/backends/creation.py
+++ b/django/db/backends/creation.py
@@ -247,6 +247,14 @@ class BaseDatabaseCreation(object):
verbosity=max(verbosity - 1, 0),
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