scripting ipython through django's shell_plus

前提是你 提交于 2019-12-24 01:01:55

问题


I'm writing a shell script which runs a command through ipython with the -c option like this:

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:

$ ./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?


回答1:


There are a couple of ways to do this.

  1. Modify manage.py and add the -c option and remove it from sys.argv after processing
  2. Modify manage.py and monkeypatch shell_plus so it supports -c by default
  3. Put your code in some file and call 'PYTHONSTARTUP=your_file ./manage.py shell_plus'


来源:https://stackoverflow.com/questions/1266702/scripting-ipython-through-djangos-shell-plus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!