How do you reload a Django model module using the interactive interpreter via “manage.py shell”?

前端 未结 9 1072
广开言路
广开言路 2020-11-28 02:14

I know how to reload a regular Python module within a regular Python interpreter session. This question documents how to do that pretty well:

How do I unload (reload

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 03:10

    From the answers of Seti Volkylany and pv

    1. Install IPython: pip install ipython
    2. Run python manage.py shell : the symbol at the beginning of a line should now be In [1]: (in cmd it was >>>)
    3. Run ipython profile create
    4. Go in ~/.ipython/profile_default/ipython_config.py and open it in a text editor and add these two lines at the end:

      c.InteractiveShellApp.extensions = ['autoreload']
      c.InteractiveShellApp.exec_lines = ['%autoreload 2']

    You can now run python manage.py shell, edit your models without having to write %autoreload 2

提交回复
热议问题