开发者

display all objects

I'm new to django. I'm trying to display all post from post model. But its not working. please help me. 'now':now is working fine. thanks

def disp开发者_如何学Golay_all_post(request):
   now = datetime.datetime.now()
   posts = Post.objects.all()
   return render_to_response('index.html',{'posts':posts,'now':now})

here is my template

    {% for post in posts.object_list %}
        {{post.title}}
        {{post.body}}
    {% endfor %}


Remove object_list attribute from posts in the template:

 {% for post in posts %}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜