Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 通过django'编写ipython脚本;s shell_plus_Linux_Django_Shell_Ipython - Fatal编程技术网

Linux 通过django'编写ipython脚本;s shell_plus

Linux 通过django'编写ipython脚本;s shell_plus,linux,django,shell,ipython,Linux,Django,Shell,Ipython,我正在编写一个shell脚本,它使用-c选项通过ipython运行命令,如下所示: ipython -c "from blah import myfunct; myfunct()" 但是我想通过django的shell_plus命令调用ipython,这样我就可以利用shell_plus为我自动加载的所有内容: $ ./manage.py shell_plus 我不能在结尾加“-c…”,因为manage.py不知道该怎么处理它。有没有办法以某种方式将-c选项导入管道?有几种方法可以做到这一点

我正在编写一个shell脚本,它使用-c选项通过ipython运行命令,如下所示:

ipython -c "from blah import myfunct; myfunct()"
但是我想通过django的shell_plus命令调用ipython,这样我就可以利用shell_plus为我自动加载的所有内容:

$ ./manage.py shell_plus

我不能在结尾加“-c…”,因为manage.py不知道该怎么处理它。有没有办法以某种方式将-c选项导入管道?

有几种方法可以做到这一点

  • 修改manage.py并添加-c选项,并在处理后将其从sys.argv中删除
  • 修改manage.py和monkeypatch shell_plus,使其默认支持-c
  • 将代码放入某个文件中,并调用
    'PYTHONSTARTUP=your_文件。/manage.py shell_plus'

  • 注意:Django检查
    PYTHONSTARTUP
    是否是带有
    os.path.isfile(pythonrc)
    的文件,这意味着它不会扩展路径。因此,如果您的
    PYTHONSTARTUP
    ~
    开头,它将不会被导入