在Django模板中访问会话内的会话

时间:2015-05-05 05:35:41

标签: python django templates session

这是我的观看代码

def edit_previous(request):
    curr_page_id= request.session['event_id']
    request.session[curr_page_id]['ep_name'] = request.POST.get('ep_name')
    print request.session[curr_page_id]['ep_name']
return render(request,'pages/edit-info.html')

我需要根据当前页面ID ...

访问模板中的会话值
{% with curr_page_id = request.session.event_id %}
{{ request.session.curr_page_id.ep_name }}
{% endwith %}
{{request.session.587.ep_name}}

当我在会话中使用会话时,我无法使用块访问.. 但我能够手动访问它。我怎么能访问它?

我的TEMPLATE_CONTEXT_PROCESSORS有

TEMPLATE_CONTEXT_PROCESSORS = (
# redirect to the current page
"django.core.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
'dsp.context_processors.common_content',
'dsp.context_processors.common_variables',
'inbox.context_processors.mail_variable',

0 个答案:

没有答案