#26246: Migrations fail when `'django.contrib.sites'` is included in INSTALLED_APPS -------------------------------------+------------------------------------- Reporter: agconti | Owner: nobody Type: Bug | Status: new Component: contrib.sites | Version: 1.9 Severity: Normal | Resolution: Keywords: sites, migrations, | Triage Stage: django_site, migrate | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by agconti):
* needs_better_patch: => 0 * needs_tests: => 0 * needs_docs: => 0 Old description: > When `'django.contrib.sites'` is included in INSTALLED_APPS, > > ### Running: > > {{{ > python manage.py migrate > }}} > > ### fails with: > > {{{ > django.db.utils.ProgrammingError: relation "django_site" does not > exist > LINE 1: SELECT (1) AS "a" FROM "django_sit > e" LIMIT 1 > }}} > > I have followed the docs and included `SITE_ID = 1` in my settings. > > Even more puzzling is that when I try to migrate the `sites` app > separately with `python manage.py migrate sites` it that fails with: > > {{{ > CommandError: App 'sites' does not have migrations > }}} > > This issue can be reporduced my cloning: https://github.com/agconti > /django-contrib-sites-failed-migration-example and running the > migrations. > > Do you have any idea on way resolve this? > > Installed Apps: > > {{{ > INSTALLED_APPS = ( > 'django.contrib.admin', > 'django.contrib.sites', > 'django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.messages', > 'django.contrib.staticfiles', > ) > }}} > > Migration error: > > {{{ > > (env) ustwo-nyc-conti-mbpr :: ~/dev/test-web » ./test/manage.py migrate > 128 ↵ > Operations to perform: > Apply all migrations: admin, contenttypes, auth, sessions > Running migrations: > No migrations to apply. > Traceback (most recent call last): > File "./test/manage.py", line 11, in <module> > execute_from_command_line(sys.argv) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/core/management/__init__.py", line 353, in > execute_from_command_line > utility.execute() > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/core/management/__init__.py", line 345, in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/core/management/base.py", line 348, in run_from_argv > self.execute(*args, **cmd_options) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/core/management/base.py", line 399, in execute > docs(README): updated with issue details > output = self.handle(*args, **options) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/core/management/commands/migrate.py", line 204, in handle > emit_post_migrate_signal(self.verbosity, self.interactive, > connection.alias) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/core/management/sql.py", line 50, in > emit_post_migrate_signal > using=db) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/dispatch/dispatcher.py", line 192, in send > response = receiver(signal=self, sender=sender, **named) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/contrib/sites/management.py", line 20, in > create_default_site > if not Site.objects.using(using).exists(): > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/db/models/query.py", line 651, in exists > return self.query.has_results(using=self.db) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/db/models/sql/query.py", line 501, in has_results > return compiler.has_results() > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/db/models/sql/compiler.py", line 819, in has_results > return bool(self.execute_sql(SINGLE)) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/db/models/sql/compiler.py", line 848, in execute_sql > cursor.execute(sql, params) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/db/backends/utils.py", line 79, in execute > return super(CursorDebugWrapper, self).execute(sql, params) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/db/backends/utils.py", line 64, in execute > return self.cursor.execute(sql, params) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/db/utils.py", line 95, in __exit__ > six.reraise(dj_exc_type, dj_exc_value, traceback) > File "/Users/conti/dev/test-web/env/lib/python2.7/site- > packages/django/db/backends/utils.py", line 64, in execute > return self.cursor.execute(sql, params) > django.db.utils.ProgrammingError: relation "django_site" does not exist > LINE 1: SELECT (1) AS "a" FROM "django_site" LIMIT 1 > }}} New description: When `'django.contrib.sites'` is included in INSTALLED_APPS, Running: {{{ python manage.py migrate }}} fails with: {{{ django.db.utils.ProgrammingError: relation "django_site" does not exist LINE 1: SELECT (1) AS "a" FROM "django_sit e" LIMIT 1 }}} I have followed the docs and included `SITE_ID = 1` in my settings. Even more puzzling is that when I try to migrate the `sites` app separately with `python manage.py migrate sites` it that fails with: {{{ CommandError: App 'sites' does not have migrations }}} This issue can be reporduced my cloning: https://github.com/agconti /django-contrib-sites-failed-migration-example and running the migrations. Do you have any idea on way resolve this? Installed Apps: {{{ INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.sites', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ) }}} Migration error: {{{ (env) ustwo-nyc-conti-mbpr :: ~/dev/test-web » ./test/manage.py migrate 128 ↵ Operations to perform: Apply all migrations: admin, contenttypes, auth, sessions Running migrations: No migrations to apply. Traceback (most recent call last): File "./test/manage.py", line 11, in <module> execute_from_command_line(sys.argv) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/core/management/base.py", line 399, in execute docs(README): updated with issue details output = self.handle(*args, **options) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/core/management/commands/migrate.py", line 204, in handle emit_post_migrate_signal(self.verbosity, self.interactive, connection.alias) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/core/management/sql.py", line 50, in emit_post_migrate_signal using=db) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/dispatch/dispatcher.py", line 192, in send response = receiver(signal=self, sender=sender, **named) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/contrib/sites/management.py", line 20, in create_default_site if not Site.objects.using(using).exists(): File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/db/models/query.py", line 651, in exists return self.query.has_results(using=self.db) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/db/models/sql/query.py", line 501, in has_results return compiler.has_results() File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/db/models/sql/compiler.py", line 819, in has_results return bool(self.execute_sql(SINGLE)) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/db/models/sql/compiler.py", line 848, in execute_sql cursor.execute(sql, params) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/db/utils.py", line 95, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/Users/conti/dev/test-web/env/lib/python2.7/site- packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: relation "django_site" does not exist LINE 1: SELECT (1) AS "a" FROM "django_site" LIMIT 1 }}} -- -- Ticket URL: <https://code.djangoproject.com/ticket/26246#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.9ad912739568be0b8719f6a0b50e2557%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.