请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

'NoneType' object has no attribute 'is_relation'

老师,昨天项目运行挺好的,今天创建新表时,提示如下错,解决很久,但未能解决,特地请教老师,谢谢!
项目所使用的:
Python 3.6.8
Django 2.2

manage.py@BusinessActivity > makemigrations user_operation

ssh://root@192.168.6.21:22/root/.virtualenvs/BA_env/bin/python -u /root/.pycharm_helpers/pycharm/django_manage.py makemigrations user_operation /root/wsh/my_projects/BusinessActivity
Tracking file by folder pattern: migrations
utf-8
Traceback (most recent call last):
File “/root/.pycharm_helpers/pycharm/django_manage.py”, line 52, in
run_command()
File “/root/.pycharm_helpers/pycharm/django_manage.py”, line 46, in run_command
run_module(manage_file, None, ‘main’, True)
File “/usr/local/lib/python3.6/runpy.py”, line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File “/usr/local/lib/python3.6/runpy.py”, line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File “/usr/local/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/root/wsh/my_projects/BusinessActivity/manage.py”, line 20, in
main()
File “/root/wsh/my_projects/BusinessActivity/manage.py”, line 16, in main
execute_from_command_line(sys.argv)
File “/root/.virtualenvs/BA_env/lib/python3.6/site-packages/django/core/management/init.py”, line 381, in execute_from_command_line
utility.execute()
File “/root/.virtualenvs/BA_env/lib/python3.6/site-packages/django/core/management/init.py”, line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/root/.virtualenvs/BA_env/lib/python3.6/site-packages/django/core/management/base.py”, line 323, in run_from_argv
self.execute(*args, **cmd_options)
File “/root/.virtualenvs/BA_env/lib/python3.6/site-packages/django/core/management/base.py”, line 364, in execute
output = self.handle(*args, **options)
File “/root/.virtualenvs/BA_env/lib/python3.6/site-packages/django/core/management/base.py”, line 83, in wrapped
res = handle_func(*args, **kwargs)
File “/root/.virtualenvs/BA_env/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py”, line 141, in handle
loader.project_state(),
File “/root/.virtualenvs/BA_env/lib/python3.6/site-packages/django/db/migrations/loader.py”, line 324, in project_state
return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self.unmigrated_apps))
File “/root/.virtualenvs/BA_env/lib/python3.6/site-packages/django/db/migrations/graph.py”, line 315, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
File “/root/.virtualenvs/BA_env/lib/python3.6/site-packages/django/db/migrations/migration.py”, line 87, in mutate_state
operation.state_forwards(self.app_label, new_state)
File “/root/.virtualenvs/BA_env/lib/python3.6/site-packages/django/db/migrations/operations/fields.py”, line 172, in state_forwards
delay = not old_field.is_relation
AttributeError: ‘NoneType’ object has no attribute ‘is_relation’

Process finished with exit code 1

正在回答

2回答

你可以按照下面步骤来做

  1. 删除数据库中的所有表

  2. 删除所有app下面的migration目录下的除了__init__.py的所有其他文件

然后重新migrate和makemigrations

0 回复 有任何疑惑可以回复我~
  • 提问者 winfred_wu #1
    老师,其实这个问题是什么原因导致的??
    回复 有任何疑惑可以回复我~ 2019-12-06 17:08:21
  • 提问者 winfred_wu #2
    谢谢老师,其实这个问题是什么原因导致的??
    回复 有任何疑惑可以回复我~ 2019-12-06 17:12:10
  • bobby 回复 提问者 winfred_wu #3
    migrations容易出错 所以要排查这个问题需要知道你当时做了什么操作引起的才行
    回复 有任何疑惑可以回复我~ 2019-12-06 17:43:42
提问者 winfred_wu 2019-12-06 17:07:54

谢谢老师,《Python 算法面试难点攻坚课--动态规划》新课不错,请问老师,作为Python开发者,有没有好的框架开发微服务?例如,Java开发者,可以选择Spring Boot来开发微服务。

1 回复 有任何疑惑可以回复我~
  • bobby #1
    谢谢支持, python本身也有微服务框架,只是不流行。我个人比较推荐使用python+go的方式进行微服务开发。 通信使用grpc, go语言在微服务方面发展的很不错,而且我个人也比较喜欢python+go的组合
    回复 有任何疑惑可以回复我~ 2019-12-06 17:45:03
  • bobby #2
    https://github.com/nameko/nameko 可以参考这个
    回复 有任何疑惑可以回复我~ 2019-12-06 17:46:08
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信