django runscript error: no (valid) module for script 'main' found
Running Extra scripts in Django:
-
Create
scripts
directory in your root project, next tomanage.py
:$ mkdir scripts
-
Add an empty file init.py (double underscore) into your
/scripts
directory:$ touch scripts/__init__.py
The init file is necessary so that the folder is picked up as a python package.
This is probably what you're missing.
-
Add your scripts into
/scripts
directory:$ touch scripts/main.py
-
After you edited your
main.py
script, run it with:$ python manage.py runscript script-name
Note: You shouldn’t include .py when specifying the script to run
Checkout Runscript Documentation