程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了迁移到文件时出现 KeyError大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决迁移到文件时出现 KeyError?

开发过程中遇到迁移到文件时出现 KeyError的问题如何解决?下面主要结合日常开发的经验,给出你关于迁移到文件时出现 KeyError的解决方法建议,希望对你解决迁移到文件时出现 KeyError有所启发或帮助;
C:\Users\SHRIYADAV\Desktop\Django\Roman\Apple\funsite>python manage.py makemigrations
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 "C:\Users\SHRIYADAV\anaconda3\lib\site-packages\django\core\management\__init__.py",line 419,in execute_from_command_line
    utility.execute()
  file "C:\Users\SHRIYADAV\anaconda3\lib\site-packages\django\core\management\__init__.py",line 413,in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  file "C:\Users\SHRIYADAV\anaconda3\lib\site-packages\django\core\management\base.py",line 354,in run_from_argv
    self.execute(*args,**cmd_options)
  file "C:\Users\SHRIYADAV\anaconda3\lib\site-packages\django\core\management\base.py",line 398,in execute
    output = self.handle(*args,**options)
  file "C:\Users\SHRIYADAV\anaconda3\lib\site-packages\django\core\management\base.py",line 89,in wrapped
    res = handle_func(*args,**kwargs)
  file "C:\Users\SHRIYADAV\anaconda3\lib\site-packages\django\core\management\commands\makemigrations.py",line 149,in handle
    loader.project_state(),file "C:\Users\SHRIYADAV\anaconda3\lib\site-packages\django\db\migrations\loader.py",line 335,in project_state
    return self.graph.make_state(nodes=nodes,at_end=at_end,real_apps=List(self.unmigrated_apps))
  file "C:\Users\SHRIYADAV\anaconda3\lib\site-packages\django\db\migrations\graph.py",line 315,in make_state
    project_state = self.nodes[node].mutate_state(project_state,preserve=falsE)
  file "C:\Users\SHRIYADAV\anaconda3\lib\site-packages\django\db\migrations\migration.py",in mutate_state
    operation.state_forWARDs(self.app_label,new_statE)
  file "C:\Users\SHRIYADAV\anaconda3\lib\site-packages\django\db\migrations\operations\models.py",line 318,in state_forWARDs
    renamed_model = state.models[app_label,self.old_name_lower].clone()
KeyError: ('apple','items')

当我开始项目时,我在完成了 80% 的项目后没有出现任何错误,然后我尝试检查我的迁移文件是否正常工作,然后我执行了那行代码

python manage.py makemigrations

我有 KeyError

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的迁移到文件时出现 KeyError全部内容,希望文章能够帮你解决迁移到文件时出现 KeyError所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。