mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #32153 -- Fixed management commands when using required list options.
Thanks Mark Gajdosik for the report and initial patch.
This commit is contained in:
parent
966b5b49b6
commit
f06beea929
4 changed files with 47 additions and 10 deletions
|
@ -7,6 +7,7 @@ class Command(BaseCommand):
|
|||
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)
|
||||
group.add_argument('--foo-list', type=int, nargs='+')
|
||||
group.add_argument('--append_const', action='append_const', const=42)
|
||||
group.add_argument('--const', action='store_const', const=31)
|
||||
group.add_argument('--count', action='count')
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--foo-list', nargs='+', type=int, required=True)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
for option, value in options.items():
|
||||
self.stdout.write('%s=%s' % (option, value))
|
Loading…
Add table
Add a link
Reference in a new issue