problem(?) in vote() function of views.py in tutorial04.txt of magic-removal /docs
|Reported by:||Owned by:||Jacob|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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 ...
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 ...
... but that's too ugly to be believed. So, anyways, I think there may be a problem here (but I could be wrong).