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 %}
精彩评论