django.db.migrations.exceptions.NodeNotFoundError:迁移帐户.0001_initial依赖项引用不存在的父节点 [英] django.db.migrations.exceptions.NodeNotFoundError: Migration accounts.0001_initial dependencies reference nonexistent parent node

查看:651
本文介绍了django.db.migrations.exceptions.NodeNotFoundError:迁移帐户.0001_initial依赖项引用不存在的父节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在heroku上部署我的项目,我正在使用django 3.1,但是我无法做到这一点.由于迁移,我遇到了错误.请谦虚地请您花一些时间解决这个问题.每当我运行命令 heroku run python manage.py migration 时,它就会提供以下跟踪.

I'm trying to deploy my project on heroku ,i'm using django 3.1 and i'm unable to do that. I'm getting error due to migrations. Please i humble request you to give some time to this question to resolve this problem. Whenever i run the command heroku run python manage.py migrate ,it gives following traceback.

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 92, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/loader.py", line 53, in __init__
    self.build_graph()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/loader.py", line 255, in build_graph
    self.graph.validate_consistency()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/graph.py", line 195, in validate_consistency
    [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/graph.py", line 195, in <listcomp>
    [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/graph.py", line 58, in raise_error
    raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration accounts.0001_initial dependencies reference nonexistent parent node ('auth', '0023_remove_user_current_balance')

迁移依赖性

 dependencies = [
        ('auth', '0023_remove_user_current_balance'),
    ]

account.model

account.model

GENDER_CHOICES = (
    ('male','Male'),
    ('female','Female'),
    )
class User(auth.models.AbstractUser):
    
    current_balance = models.IntegerField(("user balance"),default=0, blank=True, null=True)
    age = models.IntegerField(("age"),blank=True, null=True)
    gender = models.CharField(("gender"), max_length=50,choices=GENDER_CHOICES,null=True)
    nationality = models.CharField(("nationality"), max_length=50,null=True)

    def __str__(self):
        return "@{}".format(self.username)

当我尝试注释依赖项时,它返回了我: raise ValueError('Related model%r无法解析'%self.remote_field.model)ValueError:相关模型'auth.Group'不能为解决

When i tried to comment out the dependency , Then it returned me : raise ValueError('Related model %r cannot be resolved' % self.remote_field.model)ValueError: Related model 'auth.Group' cannot be resolved

如果需要更多代码,请在注释部分告诉我.

if more code is require then tell me in a comment section thank you.

推荐答案

我遇到了同样的问题.这是因为迁移历史不一致.因此,我删除了所有已安装应用程序中的迁移目录,然后调用了 python manage.py makemigrations 命令.新的迁移没有问题.

I had the same problem. It is because of the inconsistent migration history. So I deleted the migrations directory in all installed apps and then called python manage.py makemigrations command. The new migrations had no problem.

这篇关于django.db.migrations.exceptions.NodeNotFoundError:迁移帐户.0001_initial依赖项引用不存在的父节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆