當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。