diff --git a/docs/tutorial03.txt b/docs/tutorial03.txt index ac70cb5642..2896bc1e2f 100644 --- a/docs/tutorial03.txt +++ b/docs/tutorial03.txt @@ -258,7 +258,7 @@ provides a shortcut. Here's the full ``index()`` view, rewritten:: def index(request): latest_poll_list = Poll.objects.all().order_by('-pub_date') - return render_to_response('polls/index', {'latest_poll_list': latest_poll_list}) + return render_to_response('polls/index.html', {'latest_poll_list': latest_poll_list}) Note that we no longer need to import ``loader``, ``Context`` or ``HttpResponse``. @@ -280,7 +280,7 @@ for a given poll. Here's the view:: p = Poll.objects.get(pk=poll_id) except Poll.DoesNotExist: raise Http404 - return render_to_response('polls/detail', {'poll': p}) + return render_to_response('polls/detail.html', {'poll': p}) The new concept here: The view raises the ``django.http.Http404`` exception if a poll with the requested ID doesn't exist. @@ -296,7 +296,7 @@ rewritten:: # ... def detail(request, poll_id): p = get_object_or_404(Poll, pk=poll_id) - return render_to_response('polls/detail', {'poll': p}) + return render_to_response('polls/detail.html', {'poll': p}) The ``get_object_or_404()`` function takes a Django model module as its first argument and an arbitrary number of keyword arguments, which it passes to the @@ -306,8 +306,8 @@ exist. .. admonition:: Philosophy Why do we use a helper function ``get_object_or_404()`` instead of - automatically catching the ``*DoesNotExist`` exceptions at a higher level, - or having the model API raise ``Http404`` instead of ``*DoesNotExist``? + automatically catching the ``DoesNotExist`` exceptions at a higher level, + or having the model API raise ``Http404`` instead of ``DoesNotExist``? Because that would couple the model layer to the view layer. One of the foremost design goals of Django is to maintain loose coupling. diff --git a/docs/tutorial04.txt b/docs/tutorial04.txt index 5cf23a5f5d..12947bde02 100644 --- a/docs/tutorial04.txt +++ b/docs/tutorial04.txt @@ -56,7 +56,7 @@ So let's create a ``vote()`` function in ``mysite/polls/views.py``:: selected_choice = p.choice_set.filter(pk=request.POST['choice']) except (KeyError, Choice.DoesNotExist): # Redisplay the poll voting form. - return render_to_response('polls/detail', { + return render_to_response('polls/detail.html', { 'poll': p, 'error_message': "You didn't select a choice.", }) @@ -192,13 +192,13 @@ objects" and "display a detail page for a particular type of object." ``object_id`` for the generic views. By default, the ``object_detail`` generic view uses a template called -``/_detail``. In our case, it'll use the template -``"polls/poll_detail"``. Thus, rename your ``polls/detail.html`` template to +``/_detail.html``. In our case, it'll use the template +``"polls/poll_detail.html"``. Thus, rename your ``polls/detail.html`` template to ``polls/poll_detail.html``, and change the ``render_to_response()`` line in ``vote()``. Similarly, the ``object_list`` generic view uses a template called -``/_list``. Thus, rename ``poll/index.html`` to +``/_list.html``. Thus, rename ``poll/index.html`` to ``polls/poll_list.html``. Because we have more than one entry in the URLconf that uses ``object_detail``