1、查询所有的数据
def new_list(request):
articles=Article.object.order_by("-date")
return render_to_response("new_list.html",locals())
2、将数据返回列表页
newlist.py
{% for article in page %}
<li>
<div class="dttext f_l">
<ul>
<h2><a href="/new/{{ article.id }}/">{{ article.title}}</a></h2>
<p>{{ article.description }}</p>
<span>{{ article.date }}</span>
</ul>
</div>
{# <div class="xwpic f_r"><a href="/"><img src={{ article.images }}></a></div>#}
<div class="xwpic f_r"><a href="/"><img src="/static/{{ article.images}}"></a></div>
</li>
{% endfor %}
3、编写详情页
<!-- 可用于内容模板 -->
</div>
<ul class="about_content">
<p>{{ article.content }}</p>
<p><img src="/static/images/01.jpg"></p>
<p>“冥冥中该来则来,无处可逃”。 </p>
</ul>
4、关联a标签