Django:无法呈现请求上下文

时间:2011-08-19 15:11:47

标签: django requestcontext

我在views.py中有这个:

def announcements(request):
    return render_to_response('events.html', {
        'posts1': Blog.objects.filter(category__title="Announcements")
         }, context_instance=RequestContext(request)
    )

这是我的base.html:

{{ posts1 }}

但是当我加载主页时,上面的请求上下文中没有任何内容被渲染。

编辑1:

看起来我在这里走错了路。我的目标是在我的网站的固定边栏中显示“公告”类别下的帖子。无论打开哪个页面,该页面中的侧边栏都应仅包含“公告”类别中的帖子。有关如何实现它的任何建议吗?

1 个答案:

答案 0 :(得分:2)

创建inclusion template tag并在要显示该侧边栏的模板中使用它。