diff options
| author | Alasdair Nicol <alasdair@thenicols.net> | 2015-09-06 12:17:59 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-09-07 08:13:34 -0400 |
| commit | 19f98946f2b31b62303aedb5b30951ca295116d8 (patch) | |
| tree | 18ebec3aefb9cc794d4ea8d16c40020a68306f8d /docs/intro/tutorial04.txt | |
| parent | 49eee84245b1297a84ad4ddc2251e287ef585ea2 (diff) | |
Fixed #25358 -- Improved variable name for question in tutorial.
Diffstat (limited to 'docs/intro/tutorial04.txt')
| -rw-r--r-- | docs/intro/tutorial04.txt | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/intro/tutorial04.txt b/docs/intro/tutorial04.txt index 2d09de9579..716ab73a4d 100644 --- a/docs/intro/tutorial04.txt +++ b/docs/intro/tutorial04.txt @@ -76,13 +76,13 @@ create a real version. Add the following to ``polls/views.py``: from .models import Choice, Question # ... def vote(request, question_id): - p = get_object_or_404(Question, pk=question_id) + question = get_object_or_404(Question, pk=question_id) try: - selected_choice = p.choice_set.get(pk=request.POST['choice']) + selected_choice = question.choice_set.get(pk=request.POST['choice']) except (KeyError, Choice.DoesNotExist): # Redisplay the question voting form. return render(request, 'polls/detail.html', { - 'question': p, + 'question': question, 'error_message': "You didn't select a choice.", }) else: @@ -91,7 +91,7 @@ create a real version. Add the following to ``polls/views.py``: # Always return an HttpResponseRedirect after successfully dealing # with POST data. This prevents data from being posted twice if a # user hits the Back button. - return HttpResponseRedirect(reverse('polls:results', args=(p.id,))) + return HttpResponseRedirect(reverse('polls:results', args=(question.id,))) This code includes a few things we haven't covered yet in this tutorial: @@ -135,7 +135,7 @@ This code includes a few things we haven't covered yet in this tutorial: '/polls/3/results/' - where the ``3`` is the value of ``p.id``. This redirected URL will + where the ``3`` is the value of ``question.id``. This redirected URL will then call the ``'results'`` view to display the final page. As mentioned in :doc:`Tutorial 3 </intro/tutorial03>`, ``request`` is an |
