django runscript error: no (valid) module for script 'main' found

Running Extra scripts in Django:

  1. Create scripts directory in your root project, next to manage.py:

    $ mkdir scripts
    
  2. 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.

  3. Add your scripts into /scripts directory:

    $ touch scripts/main.py
    
  4. 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