Ticket #1704: tutorial-patch.diff
File tutorial-patch.diff, 3.4 KB (added by , 19 years ago) |
---|
-
docs/tutorial01.txt
449 449 >>> p.pub_date = datetime(2005, 4, 1, 0, 0) 450 450 >>> p.save() 451 451 452 # get_list() displays all the polls in the database.452 # objects.all() displays all the polls in the database. 453 453 >>> Poll.objects.all() 454 454 [<Poll object>] 455 455 -
docs/tutorial03.txt
360 360 361 361 <h1>{{ poll.question }}</h1> 362 362 <ul> 363 {% for choice in poll. get_choice_list%}363 {% for choice in poll.choice_set.all %} 364 364 <li>{{ choice.choice }}</li> 365 365 {% endfor %} 366 366 </ul> … … 371 371 in this case. If attribute lookup had failed, it would've tried calling the 372 372 method ``question()`` on the poll object. 373 373 374 Method-calling happens in the ``{% for %}`` loop: ``poll. get_choice_list`` is375 interpreted as the Python code ``poll. get_choice_list()``, which returns a list376 of Choice objects and is suitable for iteration viathe ``{% for %}`` tag.374 Method-calling happens in the ``{% for %}`` loop: ``poll.choice_set.all`` is 375 interpreted as the Python code ``poll.choice_set.all()``, which returns an 376 iterable of Choice objects and is suitable for use in the ``{% for %}`` tag. 377 377 378 378 See the `template guide`_ for full details on how templates work. 379 379 -
docs/tutorial04.txt
39 39 Django; it's just good Web development practice. 40 40 41 41 Now, let's create a Django view that handles the submitted data and does 42 something with it. Remember, in `Tutorial 3`_, we create a URLconf for the42 something with it. Remember, in `Tutorial 3`_, we created a URLconf for the 43 43 polls application that includes this line:: 44 44 45 45 (r'^(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'), … … 151 151 152 152 You should know basic math before you start using a calculator. 153 153 154 First, open the polls .py URLconf. It looks like this, according to the tutorial155 so far::154 First, open the polls/urls.py URLconf. It looks like this, according to the 155 tutorial so far:: 156 156 157 157 from django.conf.urls.defaults import * 158 158 … … 175 175 urlpatterns = patterns('', 176 176 (r'^$', 'django.views.generic.list_detail.object_list', info_dict), 177 177 (r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict), 178 (r'^(?P<object_id>\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_name='polls/results ')),178 (r'^(?P<object_id>\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_name='polls/results.html')), 179 179 (r'^(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'), 180 180 ) 181 181 … … 203 203 204 204 Because we have more than one entry in the URLconf that uses ``object_detail`` 205 205 for the polls app, we manually specify a template name for the results view: 206 ``template_name='polls/results '``. Otherwise, both views would use the same206 ``template_name='polls/results.html'``. Otherwise, both views would use the same 207 207 template. Note that we use ``dict()`` to return an altered dictionary in place. 208 208 209 209 In previous versions of the tutorial, the templates have been provided with a context