Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

magic-removal: Fixed #1464 -- Fixed error in docs/tutorial04.txt. Tha…

…nks, ubernostrum

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2733 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8b37669742c3e13549ab414d061006a75a192ae7 1 parent 121c9c9
@adrianholovaty adrianholovaty authored
Showing with 7 additions and 7 deletions.
  1. +7 −7 docs/tutorial04.txt
View
14 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.

0 comments on commit 8b37669

Please sign in to comment.
Something went wrong with that request. Please try again.