summaryrefslogtreecommitdiff
path: root/docs/tutorial04.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-04-23 21:49:07 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-04-23 21:49:07 +0000
commit8b37669742c3e13549ab414d061006a75a192ae7 (patch)
tree1b9b87be9daa4b8c378e90b50b3291ea971befa1 /docs/tutorial04.txt
parent121c9c96924615022857121225a3019f1fba8365 (diff)
magic-removal: Fixed #1464 -- Fixed error in docs/tutorial04.txt. Thanks, ubernostrum
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2733 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/tutorial04.txt')
-rw-r--r--docs/tutorial04.txt14
1 files changed, 7 insertions, 7 deletions
diff --git a/docs/tutorial04.txt b/docs/tutorial04.txt
index e67fa632bd..a0958fd341 100644
--- a/docs/tutorial04.txt
+++ b/docs/tutorial04.txt
@@ -53,7 +53,7 @@ So let's create a ``vote()`` function in ``mysite/polls/views.py``::
def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
- selected_choice = p.choice_set.filter(pk=request.POST['choice'])
+ selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the poll voting form.
return render_to_response('polls/detail.html', {
@@ -167,7 +167,7 @@ Change it like so::
from django.conf.urls.defaults import *
from mysite.polls.models import Poll
-
+
info_dict = {
'queryset': Poll.objects.all(),
}
@@ -207,18 +207,18 @@ for the polls app, we manually specify a template name for the results view:
template. Note that we use ``dict()`` to return an altered dictionary in place.
In previous versions of the tutorial, the templates have been provided with a context
-that contains the ``poll` and ``latest_poll_list`` context variables. However,
-the generic views provide the variables ``object`` and ``object_list`` as context.
-Therefore, you need to change your templates to match the new context variables.
+that contains the ``poll` and ``latest_poll_list`` context variables. However,
+the generic views provide the variables ``object`` and ``object_list`` as context.
+Therefore, you need to change your templates to match the new context variables.
Go through your templates, and modify any reference to ``latest_poll_list`` to
-``object_list``, and change any reference to ``poll`` to ``object``.
+``object_list``, and change any reference to ``poll`` to ``object``.
You can now delete the ``index()``, ``detail()`` and ``results()`` views
from ``polls/views.py``. We don't need them anymore -- they have been replaced
by generic views.
The ``vote()`` view is still required. However, it must be modified to match
-the new templates and context variables. Change the template call from ``polls/detail``
+the new templates and context variables. Change the template call from ``polls/detail``
to ``polls/polls_detail``, and pass ``object`` in the context instead of ``poll``.
Run the server, and use your new polling app based on generic views.