python manage.py migrate
django.db.utils.ProgrammingError: relation "django_site" does not exist
LINE 1: SELECT (1) AS "a" FROM "django_site" LIMIT 1
我已安装的应用中包含django.contrib.sites
,我的设置中包含SITE_ID = 1
。我还尝试使用sites
单独迁移python manage.py migrate sites
应用,但失败了:CommandError: App 'sites' does not have migrations
。
你有什么想法解决这个问题吗?
已安装的应用:
INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users',
'django.contrib.admin',
)
迁移错误:
Operations to perform:
Apply all migrations: admin, contenttypes, users, auth, sessions
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
update build with example
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying users.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying sessions.0001_initial... OK
Traceback (most recent call last):
File "./test-project/manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/Users/conti/dev/test-project/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/Users/conti/dev/test-project/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/conti/dev/test-project/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-project/env/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/Users/conti/dev/test-project/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-project/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-project/env/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 192, in send
response = receiver(signal=self, sender=sender, **named)
build without jspm for travis team
File "/Users/conti/dev/test-project/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-project/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-project/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-project/env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 823, in has_results
return bool(self.execute_sql(SINGLE))
File "/Users/conti/dev/test-project/env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 852, in execute_sql
cursor.execute(sql, params)
File "/Users/conti/dev/test-project/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-project/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-project/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-project/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
^
答案 0 :(得分:0)
通过从我的设置中删除网站迁移来解决:
MIGRATION_MODULES = {
'sites': 'contrib.sites.migrations'
}