I've a management command with the following argument parser section:
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('--out', action='store', dest='out', required=True)
parser.add_argument('--todos', action='store', dest='todos', \
required=True, nargs='+')
parser.add_argument('--filter', action='store', dest='filter')
parser.add_argument('--list', action='store', dest='list')
parser.add_argument('--add_id', action='store_true', dest='add_id')
. I'm trying to call this command from a view / shell, but does not work:
from django.core.management import call_command
call_command('prg_name', out='/tmp/111.txt')
, however i got the following error: argument --out is required .
The program is kinda old: python: 2.7 Django: 1.11.16
.
How should i call the call_command with parameters with this old layout?
What is strange, if i do this:
dt = {'--out=/tmp/111.txt': sth}
call_command(prg_name, *dt)
it works, however i can't define more value for --todos .
sthhere?*, not multiple ones), hence it will only look at the keys of the dictionaries, but you can pass a tuple, list, any iterable anyway.