summaryrefslogtreecommitdiff
path: root/django/core/management.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-08-06 05:04:27 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-08-06 05:04:27 +0000
commite301d8992cb1897cc93d84fc5d78a4c0769f5a8c (patch)
treee988b75c93a80b7dc1f67e1c479209c324369a84 /django/core/management.py
parent89d4a5659401959d976baa807c8a1fc7fa92851f (diff)
Fixed #5082 -- Enabled tab completion in 'django-admin.py shell' for objects that were imported into the global namespace at runtime. Thanks, dusk@woofle.net
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5809 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/management.py')
-rw-r--r--django/core/management.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/django/core/management.py b/django/core/management.py
index 6da1f3ea35..0bcc612c4b 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -1300,6 +1300,10 @@ def run_shell(use_plain=False):
shell.mainloop()
except ImportError:
import code
+ # Set up a dictionary to serve as the environment for the shell, so
+ # that tab completion works on objects that are imported at runtime.
+ # See ticket 5082.
+ imported_objects = {}
try: # Try activating rlcompleter, because it's handy.
import readline
except ImportError:
@@ -1308,8 +1312,9 @@ def run_shell(use_plain=False):
# We don't have to wrap the following import in a 'try', because
# we already know 'readline' was imported successfully.
import rlcompleter
+ readline.set_completer(rlcompleter.Completer(imported_objects).complete)
readline.parse_and_bind("tab:complete")
- code.interact()
+ code.interact(local=imported_objects)
run_shell.args = '[--plain]'
def dbshell():
@@ -1424,7 +1429,7 @@ def load_data(fixture_labels, verbosity=1):
print "Installing %s fixture '%s' from %s." % \
(format, fixture_name, humanize(fixture_dir))
try:
- objects = serializers.deserialize(format, fixture)
+ objects = serializers.deserialize(format, fixture)
for obj in objects:
count[0] += 1
models.add(obj.object.__class__)