开发者

Django: Failure to render Request Context

I have this in my views.py:

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

And this in my base.html:

{{ posts1 }}

But nothing from the above request context gets rendered when I load the home page.

Edit 1:

It looks like I am on a wrong path here. My aim is to display the posts under "announcement" category throughout my开发者_运维百科 website in a fixed sidebar. Whichever page is opened the sidebar in that page should contain only posts from "announcement" category. Any suggestion for how to achieve it?


Create an inclusion template tag and use it in templates where you want to display that sidebar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜