Ticket #1704: tutorial-patch.diff

File tutorial-patch.diff, 3.4 KB (added by Malcolm Tredinnick <malcolm@…>, 18 years ago)

Small tutorial fixes from reports by other people

  • docs/tutorial01.txt

     
    449449    >>> p.pub_date = datetime(2005, 4, 1, 0, 0)
    450450    >>> p.save()
    451451
    452     # get_list() displays all the polls in the database.
     452    # objects.all() displays all the polls in the database.
    453453    >>> Poll.objects.all()
    454454    [<Poll object>]
    455455
  • docs/tutorial03.txt

     
    360360
    361361    <h1>{{ poll.question }}</h1>
    362362    <ul>
    363     {% for choice in poll.get_choice_list %}
     363    {% for choice in poll.choice_set.all %}
    364364        <li>{{ choice.choice }}</li>
    365365    {% endfor %}
    366366    </ul>
     
    371371in this case. If attribute lookup had failed, it would've tried calling the
    372372method ``question()`` on the poll object.
    373373
    374 Method-calling happens in the ``{% for %}`` loop: ``poll.get_choice_list`` is
    375 interpreted as the Python code ``poll.get_choice_list()``, which returns a list
    376 of Choice objects and is suitable for iteration via the ``{% for %}`` tag.
     374Method-calling happens in the ``{% for %}`` loop: ``poll.choice_set.all`` is
     375interpreted as the Python code ``poll.choice_set.all()``, which returns an
     376iterable of Choice objects and is suitable for use in the ``{% for %}`` tag.
    377377
    378378See the `template guide`_ for full details on how templates work.
    379379
  • docs/tutorial04.txt

     
    3939      Django; it's just good Web development practice.
    4040
    4141Now, 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 the
     42something with it. Remember, in `Tutorial 3`_, we created a URLconf for the
    4343polls application that includes this line::
    4444
    4545    (r'^(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'),
     
    151151
    152152    You should know basic math before you start using a calculator.
    153153
    154 First, open the polls.py URLconf. It looks like this, according to the tutorial
    155 so far::
     154First, open the polls/urls.py URLconf. It looks like this, according to the
     155tutorial so far::
    156156
    157157    from django.conf.urls.defaults import *
    158158
     
    175175    urlpatterns = patterns('',
    176176        (r'^$', 'django.views.generic.list_detail.object_list', info_dict),
    177177        (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')),
    179179        (r'^(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'),
    180180    )
    181181
     
    203203
    204204Because we have more than one entry in the URLconf that uses ``object_detail``
    205205for the polls app, we manually specify a template name for the results view:
    206 ``template_name='polls/results'``. Otherwise, both views would use the same
     206``template_name='polls/results.html'``. Otherwise, both views would use the same
    207207template. Note that we use ``dict()`` to return an altered dictionary in place.
    208208
    209209In previous versions of the tutorial, the templates have been provided with a context
Back to Top