I am trying to call collectstatic command usig call_command but when I want to use option like -l or --noinput
django.core.management.call_command('collectstatic','--noinput')
Its giving me an error
CommandError: Command doesn't accept any arguments
Please let me know how can I call this, how to pass this options.
Thanks in Advance
1) python manage.py runserver It means to run a emulated server on your local computer. So, after running it, you can go to localhost:8000 or 127.0. 0.1:8000. Requirements: You must run this in the ROOT of your django project where manage.py lives.
This is covered in Django's official Documentation: (https://docs.djangoproject.com/en/1.8/ref/django-admin/#running-management-commands-from-your-code) the proper way to call the command should be:
from django.core.management import call_command
call_command('collectstatic', verbosity=0, interactive=False)
Check the source code of collectstatic.py
Inside add_arguments
function, the dest
keyword is what you are looking for. You then pass that value to call_command()
as argument.
EDIT: However, looking more carefully, I see that, -l
, -c
, -n
have no dest
. Thus it's unclear know how to pass those arguments :(
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With