140π
Simply install ipython
into your virtualenv. manage.py shell
should use it by default.
You can also use manage.py shell
with the -i
option to explicitly select a shell (the options are ipython
, bpython
, or python
for a regular Python shell):
python manage.py shell -i ipython
Either way, you do need to install ipython
into your environment, but you donβt need to make any changes to your project settings.
14π
I appreciate above answer and based on that I have written this answer.
If ipython
is already installed in your virtualenv
then any of the below command will work same (which has been already presented below after commands with sample snippets, point wise).
python manage.py shell
python manage.py -i ipython
How I solved (steps with problem & solution)?
Note: Make sure you have already activated your
virtualenv
.
- I didnβt have
ipython
installed in my Django project. Below is the error I got while trying to run Django shell inipython
environment.
(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ python manage.py shell -i ipython
CommandError: Couldn't import ipython interface.
(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$
Next I installed ipython
using below command.
pip install ipython
(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ pip install ipython
Collecting ipython
Downloading https://files.pythonhosted.org/packages/05/d7/77b7a1988c99227f52402f93fb0f7e88c97239960516f53907ebbc44149c/ipython-7.11.0-py3-none-any.whl (777kB)
...
...
|ββββββββββββββββββββββββββββββββ| 102kB 524kB/s
Installing collected packages: ipython-genutils, six, decorator, traitlets, pygments, ptyprocess, pexpect, wcwidth, prompt-toolkit, backcall, parso, jedi, appnope, pickleshare, ipython
Successfully installed appnope-0.1.0 backcall-0.1.0 decorator-4.4.1 ipython-7.11.0 ipython-genutils-0.2.0 jedi-0.15.2 parso-0.5.2 pexpect-4.7.0 pickleshare-0.7.5 prompt-toolkit-3.0.2 ptyprocess-0.6.0 pygments-2.5.2 six-1.13.0 traitlets-4.3.3 wcwidth-0.1.7
(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$
3.a) python manage.py shell -i ipython
(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ python manage.py shell -i ipython
Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 03:02:14)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: exit()
3.b) python manage.py shell
(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ python manage.py shell
Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 03:02:14)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]:
Thank you.
- [Django]-Django β iterate number in for loop of a template
- [Django]-Dynamically adding a form to a Django formset
- [Django]-Django form: what is the best way to modify posted data before validating?