在批处理文件中运行带脚本的django shell
我想问一下,怎么在一个批处理文件里运行“python manage.py shell”,然后添加一段代码“from myapp.model import Contact c = Contact.objects.all().count() print c”。这样做可以吗?
1 个回答
2
试试下面的这个:
echo "from myapp.model import Contact; c = Contact.objects.all().count(); print c" | python manage.py shell
或者可以看看这个 在Python中如何从标准输入读取?