问题很简单。
在我的每个观点中,我都需要以下代码:
def my_view(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
# Some code...
return render(request, 'polls/detail.html', {
'poll': p
# The rest of the dict...
})
所以我认为这是一个合适的情况使用context processors
.
但我不明白如何将poll_id
参数提供给我的上下文处理器函数。
每一个建议都将不胜感激。