Ticket #6546: app_settings_jannis.1.diff

File app_settings_jannis.1.diff, 1.2 KB (added by Jannis Leidel, 17 years ago)

App settings, first try

  • django/conf/__init__.py

     
    109109            else:
    110110                new_installed_apps.append(app)
    111111        self.INSTALLED_APPS = new_installed_apps
     112       
     113        # load settings from apps if not already existing in project settings
     114        for app in self.INSTALLED_APPS:
     115            try:
     116                app_settings = __import__("%s.settings" % app, {}, {}, [''])
     117                for setting in dir(app_settings):
     118                    existing = getattr(self, setting, None)
     119                    if setting == setting.upper() and existing is None:
     120                        setting_value = getattr(app_settings, setting)
     121                        if setting in tuple_settings and type(setting_value) == str:
     122                            setting_value = (setting_value,) # In case the user forgot the comma.
     123                        setattr(self, setting, setting_value)
     124            except ImportError:
     125                pass
    112126
    113127        if hasattr(time, 'tzset'):
    114128            # Move the time zone info into os.environ. See ticket #2315 for why
Back to Top