Execute a standalone Python script after having set up the Django environment.
manage.py run myscript.py is almost the same as redirecting stdin
shell command (i.e. doing
manage.py shell <
myscript.py), but with the possibility of using command line
For example if you have a file myscript.py with the following content...
import sys from myapp.models import Partner print Partner.objects.get(pk=sys.args)
... then you can run this script using:
$ python manage.py run myscript.py 101 Bäckerei Ausdemwald
This command modifies sys.args, __file__ and __name__ so that the invoked script sees them as if it had been called directly.
(This module's source code is available here.)