Skip to content

Commit

Permalink
Fixed #5082 -- Enabled tab completion in 'django-admin.py shell' for …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
adrianholovaty committed Aug 6, 2007
1 parent 89d4a56 commit e301d89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -96,6 +96,7 @@ answer newbie questions, and generally made Django that much better:
Maximillian Dornseif <md@hudora.de>
Jeremy Dunck <http://dunck.us/>
Andrew Durdin <adurdin@gmail.com>
dusk@woofle.net
Andy Dustman <farcepest@gmail.com>
Clint Ecker
enlight
Expand Down
9 changes: 7 additions & 2 deletions django/core/management.py
Expand Up @@ -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:
Expand All @@ -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():
Expand Down Expand Up @@ -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__)
Expand Down

0 comments on commit e301d89

Please sign in to comment.