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):

原文地址:https://www.cnblogs.com/tuifeideyouran/p/3853930.html