[Solved]-How to enable history in Django shell in python


You could use bpython it has history enabled and many other fantastic features, if you are using virtualenv install it with pip.

pip install bpython

or globally

apt-get install bpython

For me this is the most amazing interactive shell for python.


Do you have IPython installed?

The docs mention that

The default resolution order is: bpython, ipython, python.

P.S. I haven’t used bpython but there seems to be a history too.



Try out shell_plus, which comes in django-extensions.

(venv) ➜ pip install django-extensions

Then install ipython or bypython:

(venv) ➜ pip install ipython


(venv) ➜ pip install bpython

So now you should add django-extensions to your INSTALLED_APPS:


Also, Add the below config to your settings.py module and above the INSTALLED_APPS config:

SHELL_PLUS = "ipython" # or "bpython" if you installed bpython

Then by running the below command you get history, colors, auto-imports, and more sorts of good stuff in your Django shell:

(venv) ➜ python manage.py shell_plus

Also, you can run the shell_plus with another interpreter each time you want by using its name with your command for example:

(venv) ➜ python manage.py shell_plus --bpython

And If you want to use ipython notebook your command should be like this:

(venv) ➜ python manage.py shell_plus --notebook

Leave a comment