django html render_to_response
#coding=utf-8 from django.shortcuts import render from blog.models import BlogPost from django.shortcuts import render_to_response # Create your views here. def index(request): blog_list = BlogPost.objects.all() return render_to_response('index.html',{'blog_list':blog_list})
{% for post in blog_list %} <h2>{{ post.title }}</h2> <p>{{ post.timestamp }}</p> <p>{{ post.body }}</p> {% endfor%}
for post in blog_list 中的blog_list一定要和引号中的内容相同'blog_list'