summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <saghul@gmail.com>2016-02-27 18:13:01 +0100
committerTim Graham <timograham@gmail.com>2016-03-08 08:37:14 -0500
commit6c33e7333336487a30dbd170c93b2f6e50133de7 (patch)
tree4c164380aea245fa2fa3a062d32bc1b1f25d74f4
parent839a955d08fa0657622ed9b60fdd262658fa659f (diff)
Fixed #26289 -- Enabled shell tab completion on systems using libedit.
-rw-r--r--django/core/management/commands/shell.py8
-rw-r--r--docs/releases/1.10.txt3
2 files changed, 10 insertions, 1 deletions
diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
index dfc7d78691..bd61940aba 100644
--- a/django/core/management/commands/shell.py
+++ b/django/core/management/commands/shell.py
@@ -69,7 +69,13 @@ class Command(BaseCommand):
# we already know 'readline' was imported successfully.
import rlcompleter
readline.set_completer(rlcompleter.Completer(imported_objects).complete)
- readline.parse_and_bind("tab:complete")
+ # Enable tab completion on systems using libedit (e.g. Mac OSX).
+ # These lines are copied from Lib/site.py on Python 3.4.
+ readline_doc = getattr(readline, '__doc__', '')
+ if readline_doc is not None and 'libedit' in readline_doc:
+ readline.parse_and_bind("bind ^I rl_complete")
+ else:
+ readline.parse_and_bind("tab:complete")
# We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system
# conventions and get $PYTHONSTARTUP first then .pythonrc.py.
diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt
index 4f10dc1cd9..47c964292f 100644
--- a/docs/releases/1.10.txt
+++ b/docs/releases/1.10.txt
@@ -285,6 +285,9 @@ Management Commands
* To assist with testing, :func:`~django.core.management.call_command` now
accepts a command object as the first argument.
+* The :djadmin:`shell` command supports tab completion on systems using
+ ``libedit``, e.g. Mac OSX.
+
Migrations
~~~~~~~~~~