summaryrefslogtreecommitdiff
path: root/docs/tutorial03.txt
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2006-04-17 07:02:18 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2006-04-17 07:02:18 +0000
commit8f41483c2792b7288aa3530c015369ec5f9026ed (patch)
treeb2b2c9b84dc323f5e8f82dc849bcc796fc62b377 /docs/tutorial03.txt
parentcf55b5bbaf3e99c48cea68bd4a896a691c647ddc (diff)
magic-removal: Updated template names to include '.html' in tutorial.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2707 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/tutorial03.txt')
-rw-r--r--docs/tutorial03.txt10
1 files changed, 5 insertions, 5 deletions
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.