记django的一个坑:django.db.migrations.loader.BadMigrationError: Migration 0001_squashed_0002_remove_content_type_name in app contenttypes has no Migration class

作者在 2015-12-06 19:07:33 发布以下内容

今天执行djangod的合并迁移的时候运行了:

./manage.py squashmigrations contenttypes 0002

然后再执行迁移命令就出现错误提示:

django.db.migrations.loader.BadMigrationError: Migration 0001_squashed_0002_remove_content_type_name in app contenttypes has no Migration class

然后删除了网站所有migrations目录下的文件,清空了django_content_type和django_migrations数据表都不管用,在网站下搜索也搜不到0001_squashed_0002_remove_content_type_name相关的文件,找遍了谷歌也没找到相关的问题。。。。。


最后搜索整个系统根目录:

find /|ag '0001_squashed_0002'

找到症结:

/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/migrations/0001_squashed_0002_remove_content_type_name.py
/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/migrations/0001_squashed_0002_remove_content_type_name.pyc
删除这两个文件,问题解决


谨记:执行 ./manage.py squashmigrations 的时候千万不要动admin、auth、contenttypes、sessions这4个app


Python | 阅读 4487 次
文章评论,共0条
游客请输入验证码
浏览2781102次
文章归档