﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1663	problem(?) in vote() function of views.py in tutorial04.txt of magic-removal /docs	jheasly@…	Jacob	"I'm heeding Adrian's call for m-r doc nitpicks.

My Python is pretty basic, but in the section of the m-r tutorial04.txt where the vote() function is defined, the code has this:

{{{
def vote(request, poll_id):
    ...
    selected_choice = p.choice_set.filter(pk=request.POST['choice'])
    ...
    selected_choice.votes += 1
    ...
}}}
The {{{pk=}}} lookup returns a {{{selected_choice}}} that is a {{{<class 'django.db.models.query.QuerySet'>}}}, but that particular creature has no attribute {{{votes}}} to be incremented by the code a few lines further down, so it throws an {{{AttributeError}}} exception. I'm sure it's just a minor tweak of how you talk to the {{{QuerySet class}}}, but that is black magic that's way beyond me.

FWIW, I was able to poke around and find the {{{votes}}} attibute in the list returned by doing a ... 
{{{
    dir(selected_choice.model.objects.all()[0])
}}}
 ... but that's too ugly to be believed. So, anyways, I think there may be a problem here (but I could be wrong).
"	defect	closed	Documentation	magic-removal	normal	fixed			Unreviewed	0	0	0	0	0	0
