Ticket #4731: setup_environ.patch

File setup_environ.patch, 1.1 KB (added by Chris Beaven, 17 years ago)
  • django/core/management.py

     
    16441644    # Add this project to sys.path so that it's importable in the conventional
    16451645    # way. For example, if this file (manage.py) lives in a directory
    16461646    # "myproject", this code would add "/path/to/myproject" to sys.path.
    1647     project_directory = os.path.dirname(settings_mod.__file__)
     1647    project_directory, settings_filename = os.path.split(settings_mod.__file__)
    16481648    project_name = os.path.basename(project_directory)
     1649    settings_name = os.path.splitext(settings_filename)[0]
    16491650    sys.path.append(os.path.join(project_directory, '..'))
    16501651    project_module = __import__(project_name, {}, {}, [''])
    16511652    sys.path.pop()
    16521653
    16531654    # Set DJANGO_SETTINGS_MODULE appropriately.
    1654     os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % project_name
     1655    os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name)
    16551656    return project_directory
    16561657
    16571658def execute_manager(settings_mod, argv=None):
Back to Top