The project that I'm recently working on load initial data by running a script:
python manage.py shell < add_initial_data.py
I'm making functional tests now and have to call this command to load initial data in the test database.
I'm trying to use subprocess.call
and call_command
to run that script but I can't find the option to redirect the script file to shell
.
Is there a way to do that?
I've tried with
subprocess.call(['python', 'manage.py', 'shell', '<', 'add_initial_data.py'])
and
call_command('shell', '<', 'add_initial_data.py')
but gives error not recognizing < add_initial_data.py