【问题标题】:Run a django shell in batch file with script使用脚本在批处理文件中运行 django shell
【发布时间】:2014-05-04 04:56:27
【问题描述】:

我想问如何制作一个“python manage.py shell”并添加一个“from myapp.model import Contact c = Contact.objects.all().count() print c”。这可能在批处理文件中吗?

【问题讨论】:

    标签: python django django-shell


    【解决方案1】:

    尝试类似:

    echo "from myapp.model import Contact; c = Contact.objects.all().count(); print c" | python manage.py shell
    

    或者这个How do you read from stdin in Python?

    【讨论】:

    • 我试过了,它只是显示命令提示符然后关闭。
    • 谢谢。这真的帮助了我。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2018-04-10
    • 1970-01-01
    • 2021-11-16
    • 2023-03-23
    • 1970-01-01
    • 2011-09-30
    • 2020-10-08
    • 1970-01-01
    相关资源
    最近更新 更多