4👍
✅
Just pass them as keyword arguments:
call_command('download',
url="http://some-link.com/download/",
username="admin",
password="admin")
The keyword arguments should reflect the dest
values of your custom management command arguments.
Example for flush
command:
--initial-data
command-line argument in call_command()
can be set by passing load_initial_data
keyword argument:
call_command('flush', load_initial_data=False)
This is because it is --initial-data
‘s argument destination:
parser.add_argument('--no-initial-data', action='store_false',
dest='load_initial_data', default=True,
help='Tells Django not to load any initial data after database synchronization.')
Source:stackexchange.com