Using the Django shell

With the virtual environment activated and your project directory selected as the current directory, enter the following command in your command-line tool:

(myproject_env)$ python3 manage.py shell

If you are using a Docker project, this process is similar; however, first you need to connect to your app:

$ docker-compose exec app /bin/bash
/usr/src/app# python3 manage.py shell

By executing the preceding command, you will get into an interactive Python shell, configured for your Django project, where you can play around with the code, inspect the classes, try out methods, or execute scripts on the fly. In this recipe, we will go over the most important functions that you need to know in order to work with the Django shell.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.98.148