[英]Django: cannot import name migrations
I had an issue I just posted here . 我有一个问题刚在这里发布。 I saw an answer to a similar question which said uninstalling and installing
requirements.txt
would help because the root of the issue was a bad dependency chain. 我看到了一个类似问题的答案,该问题表示卸载和安装
requirements.txt
会有所帮助,因为问题的根源是不良的依赖链。
So I did that and now, of course, I ran into a new issue. 所以我这样做了,现在,我当然遇到了一个新问题。
When running the migrations, I am getting the following error: 运行迁移时,出现以下错误:
File "C:\Python27\lib\site-packages\genericm2m\migrations\0001_initial.py", line 5, in <module>
from django.db import migrations, models
ImportError: cannot import name migrations
According to another answer, this is caused because I am using the migrations module, which my Django version (1.4) doesn't support yet. 根据另一个答案,这是由于我使用的是Migrations模块引起的,我的Django版本(1.4)尚不支持该模块。
It seems like the django-generic-m2m
module (version 0.3.1) is using migrations. 似乎
django-generic-m2m
模块(版本0.3.1)正在使用迁移。 I don't understand why this issue is happening now, as I have always used the same requirements.txt
file and I never had this problem. 我不明白为什么现在会发生此问题,因为我一直使用相同的
requirements.txt
文件,而且从未遇到过此问题。
I used to have similar problems with dependencies using migrations while my Django couldn't handle them. 我曾经在使用迁移的依赖项上遇到过类似的问题,而我的Django无法处理它们。 But these deps also had a
south_migrations
folder, so just renaming it to migrations
and getting rid of the actual migrations
folder would do the trick. 但是这些部门也有一个
south_migrations
文件夹,因此只需将其重命名为migrations
并摆脱实际的migrations
文件夹即可。 However, I don't see any south_migrations
directory in the generic2m2
installation dir. 但是,我在
generic2m2
安装目录generic2m2
不到任何south_migrations
目录。
Has anybody had this issue before? 有人遇到过这个问题吗?
The app does not have South migrations, and as far as I can find, it never had them. 该应用程序没有向南迁移,据我所知,它从来没有。 It probably used to rely on 'syncdb' to create the database tables.
它可能曾经依靠“ syncdb”来创建数据库表。
Newer Django doesn't have syncdb, so migrations to create the tables were added. 较新的Django没有syncdb,因此添加了创建表的迁移。
If you are used to renaming migrations directories anyway, then you could probably just remove the migrations/ directory, but you should really upgrade to a supported version. 如果仍然习惯于重命名迁移目录,则可能只需删除migrations /目录,但实际上应该升级到受支持的版本。
Also, your old fix of renaming south_migrations to migrations wasn't the intended use: if you use Django-South 1.0 (the last version of django-south ever), it will detect when a south_migrations directory is present and use it instead of the migrations directory. 另外,将South_migrations重命名为迁移的旧方法也不是预期的用途:如果使用Django-South 1.0(曾经的django-south的最新版本),它将检测何时存在south_migrations目录,并使用它代替迁移目录。
So you should also update South to 1.0, and then adding an empty south_migrations/ directory may also work (I don't know). 因此,您还应该将South更新为1.0,然后添加一个空的south_migrations /目录也可能有效(我不知道)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.