id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 16515 Testing with multiple databases assumes sites app installed on all of them Ryan Fugger nobody "I am trying to run tests on a project with two databases. One of them has all the default django apps installed on them, including sites. The other has some of my own apps. When creating the test databases, I get the following error: {{{ [...] File ""/home/ryan/projects/villages/django/db/backends/creation.py"", line 256, in create_test_db if Site is not None and Site.objects.using(self.connection.alias).count() == 1: File ""/home/ryan/projects/villages/django/db/models/query.py"", line 331, in count return self.query.get_count(using=self.db) File ""/home/ryan/projects/villages/django/db/models/sql/query.py"", line 406, in get_count number = obj.get_aggregation(using=using)[None] File ""/home/ryan/projects/villages/django/db/models/sql/query.py"", line 372, in get_aggregation result = query.get_compiler(using).execute_sql(SINGLE) File ""/home/ryan/projects/villages/django/db/models/sql/compiler.py"", line 754, in execute_sql cursor.execute(sql, params) File ""/home/ryan/projects/villages/django/db/backends/postgresql_psycopg2/base.py"", line 43, in execute return self.cursor.execute(query, args) django.db.utils.DatabaseError: relation ""django_site"" does not exist LINE 1: SELECT COUNT(*) FROM ""django_site"" }}} The problem seems to come from django.db.backends.creation.!BaseDatabaseCreation.create_test_db, line 256, which checks if sites is installed, and then proceeds to query the sites table on the current database without checking that the sites table has even been created on the current database. {{{ 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) }}} This code was introduced in [16027]." Bug closed Testing framework dev Normal duplicate arv@… Unreviewed 0 0 0 0 0 0