Code

Ticket #17379: 17379-2.diff

File 17379-2.diff, 2.0 KB (added by lpiatek, 2 years ago)
Line 
1diff --git a/django/core/management/base.py b/django/core/management/base.py
2index db855e1..730bd49 100644
3--- a/django/core/management/base.py
4+++ b/django/core/management/base.py
5@@ -204,7 +204,9 @@ class BaseCommand(object):
6         stderr.
7         """
8         show_traceback = options.get('traceback', False)
9-
10+        self.stdout = options.get('stdout', sys.stdout)
11+        self.stderr = options.get('stderr', sys.stderr)
12+       
13         # Switch to English, because django-admin.py creates database content
14         # like permissions, and those shouldn't contain any translations.
15         # But only do this if we can assume we have a working settings file,
16@@ -215,6 +217,8 @@ class BaseCommand(object):
17                 from django.utils import translation
18                 saved_lang = translation.get_language()
19                 translation.activate('en-us')
20+                if int(options.get('verbosity', 1)) >= 2:
21+                    self.stdout.write("Active language set to 'en-us'.\n")
22             except ImportError, e:
23                 # If settings should be available, but aren't,
24                 # raise the error and quit.
25@@ -225,8 +229,6 @@ class BaseCommand(object):
26                 sys.exit(1)
27 
28         try:
29-            self.stdout = options.get('stdout', sys.stdout)
30-            self.stderr = options.get('stderr', sys.stderr)
31             if self.requires_model_validation:
32                 self.validate()
33             output = self.handle(*args, **options)
34diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
35index 26cbd7f..507f3a7 100644
36--- a/django/core/management/commands/shell.py
37+++ b/django/core/management/commands/shell.py
38@@ -9,6 +9,7 @@ class Command(NoArgsCommand):
39     )
40     help = "Runs a Python interactive interpreter. Tries to use IPython, if it's available."
41     shells = ['ipython', 'bpython']
42+    can_import_settings = False
43     requires_model_validation = False
44 
45     def ipython(self):