Code

Ticket #5943: 5943-django-admin-8295.diff

File 5943-django-admin-8295.diff, 974 bytes (added by i_i, 6 years ago)
Line 
1Index: django/core/management/__init__.py
2===================================================================
3--- django/core/management/__init__.py  (revision 8295)
4+++ django/core/management/__init__.py  (working copy)
5@@ -104,7 +104,9 @@
6         # Find the project directory
7         try:
8             from django.conf import settings
9-            project_directory = setup_environ(__import__(settings.SETTINGS_MODULE))
10+            settings_mod = __import__(settings.SETTINGS_MODULE, {}, {},
11+                             [settings.SETTINGS_MODULE.split('.')[-1]])
12+            project_directory = setup_environ(settings_mod)
13         except (AttributeError, EnvironmentError, ImportError):
14             project_directory = None
15 
16@@ -310,6 +312,7 @@
17 
18     # Set DJANGO_SETTINGS_MODULE appropriately.
19     os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name)
20+    return project_directory
21 
22 def execute_from_command_line(argv=None):
23     """