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
shell_plus is Django shell with autoloading of the apps database models and subclasses of user-defined classes. The --notebook argument tells shell_plus to open in a Jupyter notebook.
I'm going to start the Django shell by typing python manage.py —as so often—and then shell . This opens up a terminal. 00:30 However, it has the Django settings already imported, so it allows you to work directly from the root folder of a Django project.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With