当前位置: 首页>>代码示例>>Python>>正文


Python global_settings.TEMPLATE_CONTEXT_PROCESSORS属性代码示例

本文整理汇总了Python中django.conf.global_settings.TEMPLATE_CONTEXT_PROCESSORS属性的典型用法代码示例。如果您正苦于以下问题:Python global_settings.TEMPLATE_CONTEXT_PROCESSORS属性的具体用法?Python global_settings.TEMPLATE_CONTEXT_PROCESSORS怎么用?Python global_settings.TEMPLATE_CONTEXT_PROCESSORS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在django.conf.global_settings的用法示例。


在下文中一共展示了global_settings.TEMPLATE_CONTEXT_PROCESSORS属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_election_specific_settings

# 需要导入模块: from django.conf import global_settings [as 别名]
# 或者: from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS [as 别名]
def add_election_specific_settings(settings, full_election_app):
    election_settings_module = full_election_app + '.settings'
    elections_module = importlib.import_module(election_settings_module)

    # Set optional election-specific settings:
    for optional_election_app_setting, default in (
            ('AREAS_TO_ALWAYS_RETURN', []),
            ('GEOCODE_COUNTRY', None),
    ):
        try:
            settings[optional_election_app_setting] = \
                getattr(elections_module, optional_election_app_setting)
        except AttributeError:
            settings[optional_election_app_setting] = default

    # Make sure there's a trailing slash at the end of base MapIt URL:
    settings['MAPIT_BASE_URL'] = \
        re.sub(r'/*$', '/', elections_module.MAPIT_BASE_URL)

    # Add any election-specific context processors:
    extra_context_processors = \
        getattr(elections_module, 'TEMPLATE_CONTEXT_PROCESSORS', ())
    settings['TEMPLATE_CONTEXT_PROCESSORS'] += extra_context_processors

    # Get any election-specific people whose pages might be
    # particularly subject to vandalism (e.g. party leaders):
    settings['PEOPLE_LIABLE_TO_VANDALISM'] = \
        getattr(elections_module, 'PEOPLE_LIABLE_TO_VANDALISM', set())

    # Add any election-specific INSTALLED_APPS:
    settings['INSTALLED_APPS'].extend(
        getattr(elections_module, 'INSTALLED_APPS', [])) 
开发者ID:mysociety,项目名称:yournextrepresentative,代码行数:34,代码来源:conf.py


注:本文中的django.conf.global_settings.TEMPLATE_CONTEXT_PROCESSORS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。