Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented Sep 30, 2014

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

@nmvega

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.