7

I use Django shell_plus for testing my models and views

But when i get error then i change the code and then i have to restart my shell_plus

and then type all commands which i have typed

Is there any way that i don't need to restart shell and i can chnage the code and then test the command again

Anton Strogonoff
  • 32,294
  • 8
  • 53
  • 61
user1958218
  • 1,571
  • 3
  • 18
  • 28

2 Answers2

1

I personally in such cases just record my session from shell_plus to file, and then call this file from within shell_plus after manually reloading. Both is possible with iPython, which is used by shell_plus by default. (If you don't have iPython installed, just pip install ipython and it should automatically work after that, I think).

The recorded script is also often nice to keep as part of the project, as it's basically a small integration test. With minor modifications it could be executed outside shell as a standalone script, which is convenient.

If you definitely want to use reloading, I think this answer might be able to help you:

Community
  • 1
  • 1
Anton Strogonoff
  • 32,294
  • 8
  • 53
  • 61
0

Doing

import importlib
importlib.reload(module_you_changed)

works in some cases, but it won't reload all the modules imported by module_you_changed.

richplane
  • 537
  • 4
  • 12