我在视图中将会话变量设置为:
def festival_theme(request, year, month, day, slug):
festival = Project.objects.get(category__name=__('festival'), slug=slug)
request.session['_active_festival_id'] = festival.id
return render(request, 'web/festival/theme.html', {'festival':festival,})
比在我的上下文处理器函数中,我想获得这个会话变量的值。我怎样才能做到这一点?
我努力了:
#context_processors.py
def festivals(request):
s = SessionStore()
activeFestivalId = s['_active_festival_id']
allFestivals = Project.objects.filter(category__name='festival').order_by('-date')
return {'allFestivals':allFestivals}