Skip to content

Commit

Permalink
[1.3.X] Refs #15573, #15850: Added a check for whether the sites app …
Browse files Browse the repository at this point in the history
…is installed when creating the test database, in order to work around a bug in get_model. Thanks to adsva and carljm.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16062 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
nightflyerkilo committed Apr 21, 2011
1 parent 64995cd commit 53678ef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions django/db/backends/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,10 @@ def create_test_db(self, verbosity=1, autoclobber=False):
# 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)
if 'django.contrib.sites' in settings.INSTALLED_APPS:
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
Expand Down

0 comments on commit 53678ef

Please sign in to comment.