Ticket #9751: 06-fix-project_name-location-when-settings-is-a-module.patch

File 06-fix-project_name-location-when-settings-is-a-module.patch, 1.2 KB (added by Chris Lamb, 16 years ago)

0001-Fix-project_name-location-when-settings-is-a-module.patch

  • core/management/__init__.py

    diff --git a/core/management/__init__.py b/core/management/__init__.py
    index c4396d2..b8eca60 100644
    a b  
    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]
     
    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    # Set DJANGO_SETTINGS_MODULE appropriately.
    323330    if original_settings_path:
    324331        os.environ['DJANGO_SETTINGS_MODULE'] = original_settings_path
Back to Top