I need to inject same variables into settings.py for multiple django apps.hence i wrote a module which takes in output of local() and modifies. This works but is it the right way to do things?
def enable_theme(theme_name, container): """ Enable the settings for a custom theme, whose files should be stored in ENV_ROOT/themes/THEME_NAME (e.g., edx_all/themes/stanford). The THEME_NAME setting should be configured separately since it can't be set here (this function closes too early). An idiom for doing this is: THEME_NAME = "stanford" enable_theme(THEME_NAME) """ container["THEME_NAME"] = theme_name container['MITX_FEATURES']['USE_CUSTOM_THEME'] = True # Calculate the location of the theme's files theme_root = container['THEME_ROOT'] / "themes" / theme_name # Include the theme's templates in the template search paths container['TEMPLATE_DIRS'].append(theme_root / 'templates') container['THEME_SASS_DIRECTORY'] = theme_root / 'static/saas' container['MAKO_TEMPLATES']['main'].append(theme_root / 'templates') # Namespace the theme's static files to 'themes/<theme_name>' to # avoid collisions with default edX static files container['STATICFILES_DIRS'].append((u'themes/%s' % theme_name, theme_root / 'static')) container['FAVICON_PATH'] = 'themes/%s/images/favicon.ico' % theme_name #Test case from theming_utils.template_customizer import enable_theme THEME_NAME = "sokratik" PIPELINE = False MITX_FEATURES['USE_DJANGO_PIPELINE'] = False DEBUG = True TEMPLATE_DEBUG = True enable_theme(THEME_NAME, locals())