Fixed #3381 - manage.py shell now respects PYTHONSTARTUP/.pythonrc.py.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6231 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2007-09-14 22:16:14 +00:00
parent 17cd87a264
commit 27d027782c
1 changed files with 13 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import os
from django.core.management.base import NoArgsCommand
from optparse import make_option
@ -43,4 +44,16 @@ class Command(NoArgsCommand):
import rlcompleter
readline.set_completer(rlcompleter.Completer(imported_objects).complete)
readline.parse_and_bind("tab:complete")
# We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system
# conventions and get $PYTHONSTARTUP first then import user.
if not use_plain:
pythonrc = os.environ.get("PYTHONSTARTUP")
if pythonrc and os.path.isfile(pythonrc):
try:
execfile(pythonrc)
except NameError:
pass
# This will import .pythonrc.py as a side-effect
import user
code.interact(local=imported_objects)