As we saw in the previous tutorial where I have shared simple commands to start with your first Django project. In this tutorial, I will be sharing command to open Python shell in Django.
Many of the developers even don’t know if there is an interactive shell we can open in Django project. What they do is, make the code changes, start the server and check the output in the browser.
If this is working fine…
Sometimes you need to test some sort of code before putting into the Django project.
If you have Python Shell open for your Django project, you can simply run your commands and test the code.
You can test the code or feature provided by the Django which you can not test in our usual Python interpreter shell.
In Django project directory, you can see
manage.py file. It manages all the important features for Django. You can use it for our purpose now.
Follow the steps.
manage.pyin your current directory.
python manage.py shell
This interactive shell is similar to the interactive shell that we have for Python, though it looks kinda different.
In this shell, you can run all the basic code as you run on our python basic interactive shell. Moreover, you can import all the libraries which you have installed for Django project and test the code.
As usual, like our Python shell, follow the steps.
You will come out of the python Django shell.
Now you can open Python shell in Django, run your commands and exit shell. If you have any question to ask related to this topic, write in the comment.