django ipython shell_通過django的shell_plus編寫ipython腳本
I'm writing a shell script which runs a command through ipython with the -c option like this:
我正在編寫一個(gè)shell腳本,它通過ipython運(yùn)行一個(gè)命令,使用-c選項(xiàng),如下所示:
ipython -c "from blah import myfunct; myfunct()"
but I want to invoke ipython through django's shell_plus command so I can take advantage of all the stuff shell_plus automatically loads for me:
但是我想通過django的shell_plus命令調(diào)用ipython,這樣我就可以利用shell_plus自動(dòng)為我加載的所有內(nèi)容:
$ ./manage.py shell_plus
I can't just add "-c ..." to the end of that because manage.py doesn't know what to do with it. Is there any way to pipe the -c option somehow?
我不能只在結(jié)尾加上“-c…”,因?yàn)楣芾怼y不知道該怎么處理它。有沒有什么辦法來實(shí)現(xiàn)-c選項(xiàng)呢?
1 個(gè)解決方案
#1
2
There are a couple of ways to do this.
有幾種方法可以做到這一點(diǎn)。
Modify manage.py and add the -c option and remove it from sys.argv after processing
修改管理。並添加-c選項(xiàng)並從sys中刪除。argv處理后
Modify manage.py and monkeypatch shell_plus so it supports -c by default
修改管理。py和monkeypatch shell_plus默認(rèn)支持-c
Put your code in some file and call 'PYTHONSTARTUP=your_file ./manage.py shell_plus'
將代碼放在某個(gè)文件中,並調(diào)用'PYTHONSTARTUP=your_file ./manage。py shell_plus”
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的django ipython shell_通過django的shell_plus編寫ipython腳本的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql函数使用场景_mysql的函数
- 下一篇: python django flask介