Report this

What is the reason for this report?

Run command: Python Script fails due to collectstatic

Posted on March 31, 2022

I have set up a Django website with Github following the tutorial. I have also set up an associated job, which runs a python script before every deploy. The python script fails with the following error:

elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic':
IndexError: list index out of range

I assume this is because my python script calls django.setup(), which then triggers the code above from the settings.py file. As there are no other argv in the run command the index 1 results in out of range (i.e. the run script is simply: python script.py, so no arguments)

How do I fix this? And in general, what’s the best way to run a python script that connects to my Django website?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.