django1.6读书笔记一

reporter是Article中的一个外键,我们可以有多篇文章指向同一个reporter,然后通过使用article_set.all()就可以返回其所有的headline了,也可以添加条件来筛选。

(r’^articles/(\d{4})/(\d{2})/(\d+)/$’, ’news.views.article_detail’),

/articles/2005/05/39323/的请求会变成news.views.article_detail(request, ’2005’, ’05’, ’39323’).

 

在templates中<a href="{% url 'polls:detail' poll.id 1%}">{{ poll.question }}

在urls中url(r'^(?P<poll_id>\d+)/(?P<polls_id>\d+)/', views.detail, name='detail'),

在views里中def detail(request, poll_id, polls_id):

posted on 2014-07-18 17:07  颓废的悠然  阅读(99)  评论(0编辑  收藏  举报

导航