-
-
Save Quotation/909f87320b03b028d23c to your computer and use it in GitHub Desktop.
Use ptpython for Django shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.management.commands.shell import Command as ShellCommand | |
import os | |
class Command(ShellCommand): | |
shells = ShellCommand.shells.append('ptpython') | |
def ptpython(self): | |
try: | |
# old ptpython | |
from prompt_toolkit.contrib.repl import embed | |
except ImportError: | |
# new ptpython | |
from ptpython.repl import embed | |
history_filename = os.path.expanduser('~/.ptpython_history') | |
embed(globals(), locals(), vi_mode=False, history_filename=history_filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Append is incorrect should be
ShellCommand.shells + ['ptpython']
Full version: