我想向我的所有模板顯示我的通知。在我的設置,我有:使用context_processors將字典傳遞到所有模板
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'helpers.views.notifications' ,
],
},
},
]
傭工/ views.py
def notifications():
notifications = {'A':'aaa' , 'B':'bbb' }
return {'notifications': notifications }
我什麼也沒得到我的模板 - 我究竟做錯了什麼? 模板:
{{notifications.A}}
請出示您的看法 – Alasdair