當我嘗試爲我的python項目進行遷移時出現此錯誤。 我不在哪裏看,因爲我有5個應用程序與5個模型和意見! 它與不同模型中具有相同名稱的屬性有關係嗎? (我加了related_name='+'
以避免衝突名稱)。AttributeError:'NoneType'對象沒有屬性'is_relation'
我的Django的版本是:1.11.3
這是當我試圖makemigrations我什麼終端返回:
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'
實際上最近是否修改了所有5個應用程序以及5個模型和視圖?如果沒有,該錯誤可能是由您最近的一次更改造成的。使用源代碼管理來查看發生了什麼變化並將其發佈到此處。沒有這些,或者實際的模型代碼,真的很難找到問題。 – kichik