﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32047	Required mutually exclusive groups don't work with boolean arguments.	Mark Gajdosik	Hasan Ramezani	"I have the following management command (called `test.py`):

{{{
from django.core.management import BaseCommand


class Command(BaseCommand):
    def add_arguments(self, parser):
        group = parser.add_mutually_exclusive_group(required=True)
        group.add_argument('--value', type=str)
        group.add_argument('--flag', action='store_true')

    def handle(self, *args, **options):
        pass
}}}

Running `./manage.py test --flag` or `./manage.py --value foo`, the command works as expected. Using `call_command` to call the command from my code fails if I pass `--flag`, e.g.:

{{{
from django.core.management import call_command

call_command('test', flag=True)
}}}

This gets me the following traceback:

{{{
argparse.ArgumentError: argument --flag: ignored explicit argument 'True'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File ""<input>"", line 1, in <module>
  File ""/home/mark/.local/share/virtualenvs/backend-KlVhwr95/lib/python3.8/site-packages/django/core/management/__init__.py"", line 147, in call_command
    defaults = parser.parse_args(args=parse_args)
  File ""/home/mark/.local/share/virtualenvs/backend-KlVhwr95/lib/python3.8/site-packages/django/core/management/base.py"", line 57, in parse_args
    return super().parse_args(args, namespace)
  File ""/usr/lib/python3.8/argparse.py"", line 1780, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File ""/usr/lib/python3.8/argparse.py"", line 1819, in parse_known_args
    self.error(str(err))
  File ""/home/mark/.local/share/virtualenvs/backend-KlVhwr95/lib/python3.8/site-packages/django/core/management/base.py"", line 63, in error
    raise CommandError(""Error: %s"" % message)
django.core.management.base.CommandError: Error: argument --flag: ignored explicit argument 'True'
}}}"	Bug	closed	Core (Management commands)	3.1	Normal	fixed	call_command, exclusive group, store_true, action, explicit, error	Hasan Ramezani Alex Tomic	Ready for checkin	1	0	0	0	0	0
