我试图理解这一行:url(r'^(?P<poll_id>\d+)/$', views.detail, name='detail'),
来自Django's tutorial on how to create views。
特别是,我不明白以下内容:
- ?P
- \d+
- 名称='详细信息'
网址.py
urlpatterns = patterns('',
# ex: /polls/
url(r'^$', views.index, name='index'),
# ex: /polls/5/
url(r'^(?P<poll_id>\d+)/$', views.detail, name='detail'),
# ex: /polls/5/results/
url(r'^(?P<poll_id>\d+)/results/$', views.results, name='results'),
# ex: /polls/5/vote/
url(r'^(?P<poll_id>\d+)/vote/$', views.vote, name='vote'),
)