Skip to content

Instantly share code, notes, and snippets.

@defrex
Created September 30, 2014 19:14
Show Gist options
  • Save defrex/f4bedd533f7ff1a2c0a8 to your computer and use it in GitHub Desktop.
Save defrex/f4bedd533f7ff1a2c0a8 to your computer and use it in GitHub Desktop.
Add ptpython support to Django's shell command
from django.core.management.commands.shell import Command as ShellCommand
class Command(ShellCommand):
shells = ['ptpython', 'ipython', 'bpython']
def ptpython(self):
from prompt_toolkit.contrib.repl import embed
embed(globals(), locals(), vi_mode=False, history_filename=None)
@defrex
Copy link
Author

defrex commented Sep 30, 2014

Simply add this to one of your project's apps.

@nmvega
Copy link

nmvega commented Oct 13, 2017

Alternatively, you can do this:

  1. django_admin$ pip install django-extensions

  2. Append django_extensions (note the underscore this time) to the INSTALLED_APPS variable in settings.py (or whatever python file you use for Django settings).

  3. Finally: django_admin$ python ./manage.py shell_plus [--settings settings.py]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment