Django shell非交互模式运行 在你的py脚本中加入以下几行代码
import os,sysfrom django.core.management import setup_environimport settingssetup_environ(settings)