﻿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
26294	Clarify call_command()'s handling of args and options	Malcolm Box	nobody	"Minimal example:

management/commands/bug.py


{{{
class Command(BaseCommand):
   def add_arguments(self, parser):
       parser.add_argument('-n', action='store', dest='number', type=int)

   def handle(self, **options):
       int(options['number'])

}}}


Execute as:

{{{
./manage.py bug -n nan

error: argument -n: invalid int value: 'nan'
}}}

Test using call_command:

{{{
call_command('bug', n='nan')
}}}

Raises a ValueError trying to convert {{{options['number']}}}

The core problem seems to be that kwargs to call_command aren't passed through the argparse command processing in the way that *args is.

There's a work-around, which is to use the {{{ call_command('bug', '-n nan') }}} format - perhaps this could be called out in the docs?
"	Cleanup/optimization	closed	Documentation	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
