【发布时间】:2019-11-08 12:24:38
【问题描述】:
大家好,我是 Python Anywhere 的新手,我在 python 3.7 上运行一个 django 应用程序,我已经通过 MySQL Workbench 中的 SSH 手动添加了我需要的表和字段并运行了 [migrate.py inpectdb > / app/models.py] 然后 makemigrations 然后当我运行 Migrate 我得到这个:
ERRORS: auth.Group.permissions: (fields.E340) The field's intermediary table 'auth_group_permissions' clashes with the table name of 'app.AuthGroupPermissions'. auth.User.groups: (fields.E340) The field's intermediary table 'auth_user_groups' clashes with the table name of 'app.AuthUserGroups'. auth.User.user_permissions: (fields.E340) The field's intermediary table 'auth_user_user_permissions' clashes with the table name of 'app.AuthUserUserPermissions'.
如果我从 models.py 中删除身份验证表并尝试迁移,我会得到:
File "/usr/lib/python3.7/site-packages/MySQLdb/connections.py", line 276, in query _mysql.connection.query(self, query) django.db.utils.OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes')
根据我的阅读,它与 settings.py [INSTALLED_APPS] 冲突,但我不确定从这里到哪里才能使迁移正常工作。
【问题讨论】:
-
为什么“在 MySQL Workbench 中通过 SSH 手动添加我需要的表和字段”?这就是迁移的目的。是什么让您认为您需要这样做?
-
很酷的故事兄弟。感谢您的状态报告。
-
数据库是旧系统,来自旧系统。有很多我需要访问的预填充数据,这只是我阅读的指南中最简单的方法。
-
这里只是关于同一主题的讨论的注释:pythonanywhere.com/forums/topic/14430
标签: mysql django pythonanywhere