简体   繁体   English

删除迁移文件并获取 django.db.migrations.exceptions.NodeNotFoundError:

[英]Deleting Migration Files and Getting django.db.migrations.exceptions.NodeNotFoundError:

I have deleted all of migration files and now I am trying to $ python manage.py makemigrations but it is returning django.db.migrations.exceptions.NodeNotFoundError: Migration notifications.0001_initial dependencies reference nonexistent parent node ('blog', '0012_auto_20201118_22 55')我已经删除了所有迁移文件,现在我正在尝试$ python manage.py makemigrations但它正在返回django.db.migrations.exceptions.NodeNotFoundError: Migration notifications.0001_initial dependencies reference nonexistent parent node ('blog', '0012_auto_20201118_22 55')

How should I fix this error and start migrating from the beginning?我应该如何修复此错误并从头开始迁移? The reason for deleting the migration files is due to removing a function that kept returning an error due one of the migration files so I decided to start clean with them.删除迁移文件的原因是由于删除了一个 function,它由于其中一个迁移文件而不断返回错误,所以我决定开始清理它们。

Any ideas on what step I should take to start migrations and migrate again?关于我应该采取什么步骤来开始迁移和再次迁移的任何想法?

It looks like your notifications app references model(s) within your blog app, which means that it has migration files that are dependent on blog .看起来您的notifications应用程序在您的blog应用程序中引用了模型,这意味着它具有依赖blog的迁移文件。

To fix this you will need to clear the migrations for all of your apps, and delete your database.要解决此问题,您需要清除所有应用程序的迁移,并删除您的数据库。
It's also a good idea to delete your __pycache__ folders (they have caused migration issues for me in the past).删除你的__pycache__文件夹也是一个好主意(它们在过去给我带来了迁移问题)。

If you are using a unix-like command line, you can do this easily with the following:如果您使用的是类 unix命令行,则可以使用以下命令轻松完成此操作:

find . -path "*/migrations/*.py" -not -path "*/site-packages/*" -delete
find . -type d -name "__pycache__" -exec rm -rf {} +

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 django.db.migrations.exceptions.NodeNotFoundError - django.db.migrations.exceptions.NodeNotFoundError Django 迁移 - django.db.migrations.exceptions.NodeNotFoundError - Django migrations - django.db.migrations.exceptions.NodeNotFoundError django.db.migrations.exceptions.NodeNotFoundError:迁移accounts.0001_initial依赖项引用不存在的父节点 - django.db.migrations.exceptions.NodeNotFoundError: Migration accounts.0001_initial dependencies reference nonexistent parent node 删除我的数据库并尝试应用新的迁移后,我收到了这个错误,说 django.db.migrations.exceptions.NodeNotFoundError - After deleting my database and trying to apply a new migrations i get this errors that say django.db.migrations.exceptions.NodeNotFoundError 自定义 django 数据迁移创建记录 allauth.account EmailAddress model 返回错误 - django.db.migrations.exceptions.NodeNotFoundError: - Custom django data migration creating records allauth.account EmailAddress model returns error - django.db.migrations.exceptions.NodeNotFoundError: django.db.migrations.exceptions.NodeNotFoundError:迁移 app.0172_auto_20220603_1746 依赖 _auto_20220601_2313') - django.db.migrations.exceptions.NodeNotFoundError: Migration app.0172_auto_20220603_1746 dependencie _auto_20220601_2313') 我的项目中没有名为“帐户”的应用程序,但 django 仍然抛出 django.db.migrations.exceptions.NodeNotFoundError - No app named 'account' in my project but django still throws django.db.migrations.exceptions.NodeNotFoundError django.db.migrations.exceptions.NodeNotFoundError:运行“python manage.py migrate”时 - django.db.migrations.exceptions.NodeNotFoundError: upon running "python manage.py migrate" 在命令提示符下运行服务器时出现 django.db.migrations.exceptions.NodeNotFoundError - django.db.migrations.exceptions.NodeNotFoundError when running the server in command prompt Django压缩了迁移:NodeNotFoundError - Django squashed migrations: NodeNotFoundError
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM