Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit e301d8992cb1897cc93d84fc5d78a4c0769f5a8c 1 parent 89d4a56
Adrian Holovaty authored
1  AUTHORS
@@ -96,6 +96,7 @@ answer newbie questions, and generally made Django that much better:
96 96
     Maximillian Dornseif <md@hudora.de>
97 97
     Jeremy Dunck <http://dunck.us/>
98 98
     Andrew Durdin <adurdin@gmail.com>
  99
+    dusk@woofle.net
99 100
     Andy Dustman <farcepest@gmail.com>
100 101
     Clint Ecker
101 102
     enlight
9  django/core/management.py
@@ -1300,6 +1300,10 @@ def run_shell(use_plain=False):
1300 1300
         shell.mainloop()
1301 1301
     except ImportError:
1302 1302
         import code
  1303
+        # Set up a dictionary to serve as the environment for the shell, so
  1304
+        # that tab completion works on objects that are imported at runtime.
  1305
+        # See ticket 5082.
  1306
+        imported_objects = {}
1303 1307
         try: # Try activating rlcompleter, because it's handy.
1304 1308
             import readline
1305 1309
         except ImportError:
@@ -1308,8 +1312,9 @@ def run_shell(use_plain=False):
1308 1312
             # We don't have to wrap the following import in a 'try', because
1309 1313
             # we already know 'readline' was imported successfully.
1310 1314
             import rlcompleter
  1315
+            readline.set_completer(rlcompleter.Completer(imported_objects).complete)
1311 1316
             readline.parse_and_bind("tab:complete")
1312  
-        code.interact()
  1317
+        code.interact(local=imported_objects)
1313 1318
 run_shell.args = '[--plain]'
1314 1319
 
1315 1320
 def dbshell():
@@ -1424,7 +1429,7 @@ def load_data(fixture_labels, verbosity=1):
1424 1429
                             print "Installing %s fixture '%s' from %s." % \
1425 1430
                                 (format, fixture_name, humanize(fixture_dir))
1426 1431
                         try:
1427  
-                            objects =  serializers.deserialize(format, fixture)
  1432
+                            objects = serializers.deserialize(format, fixture)
1428 1433
                             for obj in objects:
1429 1434
                                 count[0] += 1
1430 1435
                                 models.add(obj.object.__class__)

0 notes on commit e301d89

Please sign in to comment.
Something went wrong with that request. Please try again.