1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #30763 -- Fixed management commands when using required mutually exclusive groups.

This commit is contained in:
Hasan Ramezani
2019-09-05 23:45:56 +02:00
committed by Mariusz Felisiak
parent 350123f38c
commit 6c379f1a18
3 changed files with 31 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--foo-id', type=int, nargs='?', default=None)
group.add_argument('--foo-name', type=str, nargs='?', default=None)
def handle(self, *args, **options):
self.stdout.write(','.join(options))