当我尝试为我的python项目制作数据时,会出现此错误。
我不知道在哪里看,因为我有5个应用程序,包含5个模型和视图!
它与不同模型中具有相同名称的属性有关系吗?
(我添加related_name='+'
以避免冲突名称。)
我的django版本是:1.11.3
这是我尝试制作游戏时终端返回的内容:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/user/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/user/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/user/.local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/user/.local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/user/.local/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 150, in handle
loader.project_state(),
File "/home/user/.local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 323, in project_state
return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self.unmigrated_apps))
File "/home/user/.local/lib/python2.7/site-packages/django/db/migrations/graph.py", line 409, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
File "/home/user/.local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 92, in mutate_state
operation.state_forwards(self.app_label, new_state)
File "/home/user/.local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 149, in state_forwards
delay = not old_field.is_relation
AttributeError: 'NoneType' object has no attribute 'is_relation'
答案 0 :(得分:0)
我认为您的migrate
文件有问题,如果所有文件都存在并已实施,请检查它们。我认为你存在的一些迁移文件已经消失了
答案 1 :(得分:0)
就我而言,这是由迁移问题引起的。解决此问题的最简单方法是使用django-reset-migrations重置受影响应用的迁移:https://github.com/valdergallo/django-reset-migrations