我正在pythonanywhere平台上将我的django webapp从sqlite迁移到mysql,我不断收到以下错误:
django.db.utils.OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes')
我尝试了几件事,包括答案 here但无法使其发挥作用。有什么建议吗?
我的models.py文件非常简单:
from django.db import models
class Showww(models.Model):
name = models.IntegerField()
并且完整的错误消息是:
Operations to perform:
Apply all migrations: admin, contenttypes, shows, auth, sessions
Running migrations:
Applying shows.0001_initial...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 160, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 63, in migrate
self.apply_migration(migration, fake=fake)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 97, in apply_migration
migration.apply(project_state, schema_editor)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 107, in apply
operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 36, in database_forwards
schema_editor.create_model(model)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/backends/schema.py", line 270, in create_model
self.execute(sql, params)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/backends/schema.py", line 98, in execute
cursor.execute(sql, params)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 128, in execute
return self.cursor.execute(query, args)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
self.errorhandler(self, exc, value)
File "/home/smartadds/.virtualenvs/broadwaypass/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes')