Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 27d027782cc1a99ad22105a39d3bab17ef871cf3 1 parent 17cd87a
@jacobian jacobian authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 django/core/management/commands/shell.py
View
13 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 @@ def handle_noargs(self, **options):
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)

0 comments on commit 27d0277

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