我该如何解决AttributeError'NoneType'对象没有属性'write'

时间:2020-08-12 10:03:21

标签: python django

python manage.py migration

  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 162, in handle
    self.stdout.write(self.style.MIGRATE_HEADING("Operations to perform:"))
  File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 145, in write
    self._out.write(style_func(msg))
AttributeError: 'NoneType' object has no attribute 'write'

请任何人都可以帮助解决此错误。 每当我尝试使用manage.py时,它都会弹出。任何人都可以

1 个答案:

答案 0 :(得分:0)

您可以转到 Migrations 文件夹并删除除 init .py

以外的所有文件。

然后运行

python manage.py makemigrations

python manage.py migrate