开发者

display all objects

开发者 https://www.devze.com 2023-03-14 03:13 出处:网络
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

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

精彩评论

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