def load(self):
# Make sure we load the defaults first.
super().load()
# Prepare the loading.
self.module = os.environ.get('PYPLANET_SETTINGS_MODULE')
if not self.module:
raise ImproperlyConfigured(
'Settings module is not defined! Please define PYPLANET_SETTINGS_MODULE in your '
'environment or start script.'
)
# Add the module itself to the configuration.
self.settings['SETTINGS_MODULE'] = self.module
# Load the module, put the settings into the local context.
module = importlib.import_module(self.module)
for setting in dir(module):
if setting.isupper():
self.settings[setting] = getattr(module, setting)
评论列表
文章目录