Ticket #9751: 0001-Fix-project_name-location-when-settings-is-a-module.patch

File 0001-Fix-project_name-location-when-settings-is-a-module.patch, 1.3 KB (added by lamby, 7 years ago)

Rebasing patch against HEAD

  • core/management/__init__.py

    diff --git a/core/management/__init__.py b/core/management/__init__.py
    index c4396d2..b8eca60 100644
    a b def setup_environ(settings_mod, original_settings_path=None): 
    310310    project_directory, settings_filename = os.path.split(settings_mod.__file__)
    311311    if project_directory == os.curdir or not project_directory:
    312312        project_directory = os.getcwd()
    313     project_name = os.path.basename(project_directory)
    314313
    315314    # Strip filename suffix to get the module name.
    316315    settings_name = os.path.splitext(settings_filename)[0]
    def setup_environ(settings_mod, original_settings_path=None): 
    319318    if settings_name.endswith("$py"):
    320319        settings_name = settings_name[:-3]
    321320
     321    if settings_name == '__init__':
     322        # Settings is a module; thus the project directory and settings_name
     323        # must be gleaned from one level higher up the path.
     324        project_directory = os.path.dirname(project_directory)
     325        settings_name = os.path.basename(os.path.dirname(settings_mod.__file__))
     326
     327    project_name = os.path.basename(project_directory)
     328
    322329    sys.path.append(os.path.join(project_directory, os.pardir))
    323330    project_module = __import__(project_name, {}, {}, [''])
    324331    sys.path.pop()
Back to Top