Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #4731 -- Changed management.setup_environ() so that it no longe…

…r assumes

the settings module is called "settings". Patch from SmileyChris.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5696 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a9a04ca8f67811f3e59b9ae17ae9d639311bf6e9 1 parent b8eee39
Malcolm Tredinnick authored July 14, 2007

Showing 1 changed file with 3 additions and 2 deletions. Show diff stats Hide diff stats

  1. 5  django/core/management.py
5  django/core/management.py
@@ -1713,14 +1713,15 @@ def setup_environ(settings_mod):
1713 1713
     # Add this project to sys.path so that it's importable in the conventional
1714 1714
     # way. For example, if this file (manage.py) lives in a directory
1715 1715
     # "myproject", this code would add "/path/to/myproject" to sys.path.
1716  
-    project_directory = os.path.dirname(settings_mod.__file__)
  1716
+    project_directory, settings_filename = os.path.split(settings_mod.__file__)
1717 1717
     project_name = os.path.basename(project_directory)
  1718
+    settings_name = os.path.splitext(settings_filename)[0]
1718 1719
     sys.path.append(os.path.join(project_directory, '..'))
1719 1720
     project_module = __import__(project_name, {}, {}, [''])
1720 1721
     sys.path.pop()
1721 1722
 
1722 1723
     # Set DJANGO_SETTINGS_MODULE appropriately.
1723  
-    os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % project_name
  1724
+    os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name)
1724 1725
     return project_directory
1725 1726
 
1726 1727
 def execute_manager(settings_mod, argv=None):

0 notes on commit a9a04ca

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