summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2007-09-14 22:16:14 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2007-09-14 22:16:14 +0000
commit27d027782cc1a99ad22105a39d3bab17ef871cf3 (patch)
treef13ebf953e68689843124fcfdcf0341dc83f7b04
parent17cd87a264d8719e82773ace080df25bad88cbef (diff)
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
-rw-r--r--django/core/management/commands/shell.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
index 3baf75c104..96169020e5 100644
--- a/django/core/management/commands/shell.py
+++ b/django/core/management/commands/shell.py
@@ -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)