argparse.ArgumentError: argument --skip-checks: conflicting option string: --skip-checks

argparse.ArgumentError: argument --skip-checks: conflicting option string: --skip-checks

我正在使用 django-tenant-schemas,当我尝试使用“migrate_schemas”命令时遇到错误。我在这里看到过类似的问题,但它们根本没有帮助。我在两个不同的应用程序上试过这个,但结果是一样的。有人知道如何解决这个问题吗?

    Traceback (most recent call last):
  File "C:\DjangoNew\tenancy\manage.py", line 22, in <module>
    main()
  File "C:\DjangoNew\tenancy\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 322, in run_from_argv
    parser = self.create_parser(argv[0], argv[1])
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 296, in create_parser
    self.add_arguments(parser)
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\site-packages\tenant_schemas\management\commands\migrate_schemas.py", line 20, in add_arguments
    command.add_arguments(parser)
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\migrate.py", line 28, in add_arguments
    help='Skip system checks.',
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\argparse.py", line 1373, in add_argument
    return self._add_action(action)
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\argparse.py", line 1736, in _add_action
    self._optionals._add_action(action)
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\argparse.py", line 1577, in _add_action
    action = super(_ArgumentGroup, self)._add_action(action)
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\argparse.py", line 1387, in _add_action
    self._check_conflict(action)
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\argparse.py", line 1526, in _check_conflict
    conflict_handler(action, confl_optionals)
  File "C:\Users\asyey\AppData\Local\Programs\Python\Python37\lib\argparse.py", line 1535, in _handle_conflict_error
    raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument --skip-checks: conflicting option string: --skip-checks

这是 django-tenant-schemas 中的错误。 通过阅读 Django 文档,他们似乎忘记将 requires_system_checks 设置为 False

我相信 pull request 会解决问题。

在合并此修复程序之前,您可以通过 运行 将 Django 降级到版本 2 来解决此问题,例如

pip install "Django~=2.2"

或将 INSTALLED_APPS 列表中的 tenant-schemas 移动到 settings.py 文件的底部。