mirror of
https://github.com/django/django.git
synced 2025-12-15 21:45:20 +00:00
Refs #17171 -- Updated tutorial sections 3 and 4 to follow the startproject template and consistently use url() function in URLconf. Thanks haimunt for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17073 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5f64af9ecb
commit
7f658a5429
2 changed files with 28 additions and 29 deletions
|
|
@ -221,10 +221,10 @@ tutorial so far::
|
|||
from django.conf.urls import patterns, include, url
|
||||
|
||||
urlpatterns = patterns('polls.views',
|
||||
(r'^$', 'index'),
|
||||
(r'^(?P<poll_id>\d+)/$', 'detail'),
|
||||
(r'^(?P<poll_id>\d+)/results/$', 'results'),
|
||||
(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
|
||||
url(r'^$', 'index'),
|
||||
url(r'^(?P<poll_id>\d+)/$', 'detail'),
|
||||
url(r'^(?P<poll_id>\d+)/results/$', 'results'),
|
||||
url(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
|
||||
)
|
||||
|
||||
Change it like so::
|
||||
|
|
@ -234,12 +234,12 @@ Change it like so::
|
|||
from polls.models import Poll
|
||||
|
||||
urlpatterns = patterns('',
|
||||
(r'^$',
|
||||
url(r'^$',
|
||||
ListView.as_view(
|
||||
queryset=Poll.objects.order_by('-pub_date')[:5],
|
||||
context_object_name='latest_poll_list',
|
||||
template_name='polls/index.html')),
|
||||
(r'^(?P<pk>\d+)/$',
|
||||
url(r'^(?P<pk>\d+)/$',
|
||||
DetailView.as_view(
|
||||
model=Poll,
|
||||
template_name='polls/detail.html')),
|
||||
|
|
@ -248,7 +248,7 @@ Change it like so::
|
|||
model=Poll,
|
||||
template_name='polls/results.html'),
|
||||
name='poll_results'),
|
||||
(r'^(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),
|
||||
url(r'^(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),
|
||||
)
|
||||
|
||||
We're using two generic views here:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue