Fixed #1202 -- Changed 'manage.py shell' to use IPython if present. Also added '--plain' option, which overrides IPython to use the standard Python interactive prompt
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1930 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
51f4e95cb7
commit
5e6d6fafae
|
@ -814,11 +814,19 @@ def createcachetable(tablename):
|
||||||
db.db.commit()
|
db.db.commit()
|
||||||
createcachetable.args = "[tablename]"
|
createcachetable.args = "[tablename]"
|
||||||
|
|
||||||
def run_shell():
|
def run_shell(use_plain=False):
|
||||||
"Runs a Python interactive interpreter"
|
"Runs a Python interactive interpreter. Tries to use IPython, if it's available."
|
||||||
import code
|
try:
|
||||||
code.interact()
|
if use_plain:
|
||||||
run_shell.args = ''
|
# Don't bother loading IPython, because the user wants plain Python.
|
||||||
|
raise ImportError
|
||||||
|
import IPython
|
||||||
|
shell = IPython.Shell.IPShell()
|
||||||
|
shell.mainloop()
|
||||||
|
except ImportError:
|
||||||
|
import code
|
||||||
|
code.interact()
|
||||||
|
run_shell.args = '[--plain]'
|
||||||
|
|
||||||
# Utilities for command-line script
|
# Utilities for command-line script
|
||||||
|
|
||||||
|
@ -878,6 +886,8 @@ def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING):
|
||||||
help='Python path to settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.')
|
help='Python path to settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.')
|
||||||
parser.add_option('--pythonpath',
|
parser.add_option('--pythonpath',
|
||||||
help='Lets you manually add a directory the Python path, e.g. "/home/djangoprojects/myproject".')
|
help='Lets you manually add a directory the Python path, e.g. "/home/djangoprojects/myproject".')
|
||||||
|
parser.add_option('--plain', action='store_true', dest='plain',
|
||||||
|
help='Tells Django to use plain Python, not IPython, for "shell" command.')
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
# Take care of options.
|
# Take care of options.
|
||||||
|
@ -913,7 +923,9 @@ def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
action_mapping[action](username, email, password)
|
action_mapping[action](username, email, password)
|
||||||
elif action in ('init', 'shell', 'validate'):
|
elif action == 'shell':
|
||||||
|
action_mapping[action](options.plain is True)
|
||||||
|
elif action in ('init', 'validate'):
|
||||||
action_mapping[action]()
|
action_mapping[action]()
|
||||||
elif action == 'inspectdb':
|
elif action == 'inspectdb':
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -156,6 +156,19 @@ Port 7000 on IP address 1.2.3.4::
|
||||||
|
|
||||||
django-admin.py runserver 1.2.3.4:7000
|
django-admin.py runserver 1.2.3.4:7000
|
||||||
|
|
||||||
|
shell
|
||||||
|
-----
|
||||||
|
|
||||||
|
Starts the Python interactive interpreter.
|
||||||
|
|
||||||
|
**New in Django development version:** Uses IPython_, if it's installed. If you
|
||||||
|
have IPython installed and want to force use of the "plain" Python interpreter,
|
||||||
|
use the ``--plain`` option, like so::
|
||||||
|
|
||||||
|
django-admin.py shell --plain
|
||||||
|
|
||||||
|
.. _IPython: http://ipython.scipy.org/
|
||||||
|
|
||||||
sql [modelmodule modelmodule ...]
|
sql [modelmodule modelmodule ...]
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue