思路整理
1 先在urls.py中,定义路由获取的格式
url(r'^detail/(\d+)/$', views.blog_detail),
2 然后在views.py,定义数据获取的方法
def blog_detail(request,id): blog_detail=BlogsPost.objects.get(id=id) return render(request,'detail.html', {'blog_detail':blog_detail})
3 然后在detail.html的模板页中,对数据进行展示
<h2>{{ blog_detail.title }}</h2> <p>{{ blog_detail.timestamp }}</p> <p>{{ blog_detail.body }}</p>
that's all! enjoy it!