【问题标题】:How do you solve django.db.migrations.exceptions.NodeNotFoundError in Django?你如何解决 Django 中的 django.db.migrations.exceptions.NodeNotFoundError?
【发布时间】:2022-01-09 11:45:15
【问题描述】:

python manage.py makemigrations 时出现以下错误:

django.db.migrations.exceptions.NodeNotFoundError: Migration leads.0001_initial dependencies reference nonexistent parent node ('auth', '0012_alter_user_first_name_max_length')

这是我的 0001_initial.py 的一部分:

class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0012_alter_user_first_name_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='User',
            ...

我应该如何解决这个错误?目前,我正在生产中。谢谢,如有任何问题,请发表评论。

【问题讨论】:

  • 您是否删除了任何迁移?您似乎删除了 0012_alter_user_first_name_max_length 迁移。
  • 不,我不这么认为。我不知道这是否有帮助,但我刚刚通过 filezilla 上传了我的新 django 应用程序,并安装了我所有的 pip。然后,我做了迁移,但出现了这个错误。另外,我已经在服务器中重置了我的数据库。
  • @WillemVanOnsem django 应用程序在开发过程中运行良好,并且在我进行迁移时没有任何错误。但是,我在网上上传应用后突然收到此错误。

标签: django django-models django-views django-forms django-templates


【解决方案1】:

你的问题出在 Django 版本上:

因为这个迁移文件0012_alter_user_first_name_max_length必须在这个目录下:/lib/python3.*/site-packages/django/contrib/auth/migrations/但是它现在不存在,你会收到一个错误。

在您的情况下,我认为您使用的是最旧版本的 Django(< 3.1.0),并且此迁移文件不存在,要解决此问题,您可以将 Django 版本升级到>= 3.1.0

【讨论】:

    猜你喜欢
    • 2018-11-27
    • 2018-10-01
    • 1970-01-01
    • 2010-10-24
    • 2015-12-11
    • 2022-08-21
    • 1970-01-01
    • 2023-03-05
    • 2015-05-09
    相关资源
    最近更新 更多