如何在django shell中执行python脚本文件?


写了一个python脚本文件,其中调用的django的ORM相关信息,不能直接执行,请问有什么方法能在django的shell中执行这个脚本吗?

python django shell 技巧 脚本

微雨洒庭轩 10 years, 3 months ago

你可以使用两种方法:

第一种:

$ ./manage.py shell < myscript.py

第二种方法:

$ ./manage.py shell
>>> execfile('myscript.py')
LEMO❤ answered 10 years, 3 months ago

Your Answer