How to execute a Python script from the Django shell?

The Solution to How to execute a Python script from the Django shell? is


The << part is wrong, use < instead:

$ ./manage.py shell < myscript.py

You could also do:

$ ./manage.py shell
...
>>> execfile('myscript.py')

For python3 you would need to use

>>> exec(open('myscript.py').read())

~ Answered on 2013-05-31 09:13:21


Most Viewed Questions: