本文整理匯總了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', []))