安装依赖
pip install django-extensions
pip install ipython
配置shell默认用ipython
SHELL_PLUS = "ipython"
IPYTHON_ARGUMENTS = ["--ext", "autoreload", "--automagic"]
重载代码
- 在运行时候重载
- 编辑django配置文件
settings.py
,添加如下内容
SHELL_PLUS = "ipython"
IPYTHON_ARGUMENTS = ["--ext", "autoreload", "--automagic"]
- 运行
./manage.py shell_plus
- 输入
%autoreload 2
- 编辑ipython配置
1.运行ipython profile create
2.编辑~/.ipython/profile_default/ipython_config.py
c.InteractiveShellApp.exec_lines = ['%autoreload 2']
c.InteractiveShellApp.extensions = ['autoreload']
引用