[Django] #26246: Migrations fail when `'django.contrib.sites'` is included in INSTALLED_APPS

46 views
Skip to first unread message

Django

unread,
Feb 19, 2016, 2:02:05 PM2/19/16
to django-...@googlegroups.com
#26246: Migrations fail when `'django.contrib.sites'` is included in INSTALLED_APPS
-------------------------+-------------------------------------------------
Reporter: agconti | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.9
contrib.sites | Keywords: sites, migrations, django_site,
Severity: Normal | migrate
Triage Stage: | Has patch: 0
Unreviewed |
Easy pickings: 0 | UI/UX: 0
-------------------------+-------------------------------------------------
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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 19, 2016, 2:02:31 PM2/19/16
to django-...@googlegroups.com
#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:

> Installed Apps:
>

New description:

When `'django.contrib.sites'` is included in INSTALLED_APPS,

Running:

{{{
python manage.py migrate
}}}

fails with:


Installed Apps:

Migration error:

{{{

--

--
Ticket URL: <https://code.djangoproject.com/ticket/26246#comment:1>

Django

unread,
Feb 19, 2016, 2:02:58 PM2/19/16
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------
Description changed by agconti:

Old description:

> When `'django.contrib.sites'` is included in INSTALLED_APPS,
>

> Running:
>
> {{{
> python manage.py migrate
> }}}
>
> fails with:
>

> Installed Apps:
>

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_site" LIMIT 1
}}}


Installed Apps:

Migration error:

{{{

--

--
Ticket URL: <https://code.djangoproject.com/ticket/26246#comment:2>

Django

unread,
Feb 19, 2016, 2:52:43 PM2/19/16
to django-...@googlegroups.com
#26246: Migrations fail when `'django.contrib.sites'` is included in INSTALLED_APPS
-------------------------------------+-------------------------------------
Reporter: agconti | Owner: nobody
Type: Bug | Status: closed
Component: contrib.sites | Version: 1.9
Severity: Normal | Resolution: invalid

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 timgraham):

* status: new => closed
* resolution: => invalid


Comment:

You have a custom entry in `MIGRATION_MODULES` for that app that points to
a nonexistent module: `'sites': 'contrib.sites.migrations'`.

--
Ticket URL: <https://code.djangoproject.com/ticket/26246#comment:3>

Django

unread,
Feb 19, 2016, 3:12:40 PM2/19/16
to django-...@googlegroups.com
#26246: Migrations fail when `'django.contrib.sites'` is included in INSTALLED_APPS
-------------------------------------+-------------------------------------
Reporter: agconti | Owner: nobody

Type: Bug | Status: closed
Component: contrib.sites | Version: 1.9
Severity: Normal | Resolution: invalid
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
-------------------------------------+-------------------------------------

Comment (by agconti):

Thank you. This solved my issue.

Replying to [comment:3 timgraham]:


> You have a custom entry in `MIGRATION_MODULES` for that app that points
to a nonexistent module: `'sites': 'contrib.sites.migrations'`.

--
Ticket URL: <https://code.djangoproject.com/ticket/26246#comment:4>

Reply all
Reply to author
Forward
0 new messages