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

Viewed 2004

I am working with django-tenant-schemas and when I try to use "migrate_schemas" command I encounter an error. I've seen similar questions here but they didn't help at all. I've tried this on two different apps but the result is the same. Does anybody know how to fix this?

    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
2 Answers

It is a bug in django-tenant-schemas. From reading Django documents it seems like they forgot to set requires_system_checks to False.

I believe this pull request will fix the problem.

Till this fix is merged, you can solve this by either downgrade Django to version 2 by running something like

pip install "Django~=2.2"

or move tenant-schemas at the INSTALLED_APPS list to the bottom in the settings.py file.

Error: argparse.ArgumentError: argument --email: conflicting option string: --email
If anyone here by this error from django-rest-framework

So, this error occurs because the field 'email' is required, but still in Model's REQUIRED_FIELDS list.

Just remove it from REQUIRED_FIELDS, it should work.

This scenario also possible in other attributes also.


class UserAccount(AbstractUser):
    
    first_name = ...
    last_name = ...
    email = models.EmailField(_("Email address"), unique=True, blank=False)
    

    REQUIRED_FIELDS = AbstractUser.REQUIRED_FIELDS + ['first_name', 'last_name', 'email']

    class Meta(AbstractUser.Meta):
        swappable = "AUTH_USER_MODEL"
        verbose_name = _("UserAccount")
        verbose_name_plural = _("UserAccounts")


Related