Ticket #10322: mocksoul_true_environ.patch

File mocksoul_true_environ.patch, 1.0 KB (added by MockSoul, 6 years ago)

Allow to use settings from package, e.g. app.web.settings.

  • django/core/management/__init__.py

    === modified file 'django/core/management/__init__.py'
     
    302302    project_directory, settings_filename = os.path.split(settings_mod.__file__)
    303303    if project_directory == os.curdir or not project_directory:
    304304        project_directory = os.getcwd()
    305     project_name = os.path.basename(project_directory)
     305    # Determine project name by splitting settings mod name if settings specified with project
     306    # It will be "abc" in case of "abc.settings", "a.b" in case of "a.b.settings" and
     307    # dirname of settings.py in case of "settings"
     308    if '.' in settings_mod.__name__:
     309        project_name = settings_mod.__name__[:settings_mod.__name__.rfind('.')]
     310    else:
     311        project_name = os.path.basename(project_directory)
     312   
    306313    settings_name = os.path.splitext(settings_filename)[0]
    307314    sys.path.append(os.path.join(project_directory, os.pardir))
    308315    project_module = __import__(project_name, {}, {}, [''])
Back to Top