【发布时间】:2011-06-15 10:08:50
【问题描述】:
我想仅从命令行通过 Django 的 manage.py shell 函数执行命令
例如
manage.py shell -c "from myapp import models; print models.MyModel.some_calculation()"
您可以在普通 Python 解释器中使用 -c 选项
例如
python -c "print 'hello world'"
但是,我没有看到 manage.py shell 的等效 -c 选项。有没有办法做到这一点?
【问题讨论】:
-
请不要。请写一个两行的脚本文件。
标签: python django django-shell