私はジャンゴが初めてです。
私は自分のviews.pyの下にこのコードを持っています
poll_list = []
@login_required
@never_cache
def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
return detail(request, poll_id, error_message="You didn't select a choice.")
else:
if request.session.get('voted_on', False):
poll_list = []
request.session['voted_on'] = poll_list
if poll_id in request.session.get('voted_on', []):
return detail(request, poll_id, has_voted="You have already voted.")
selected_choice.votes += 1
selected_choice.save()
poll_list.append(poll_id)
request.session['voted_on'] = poll_list
return HttpResponseRedirect(reverse('poll_results', args=(p.id,)))
return HttpResponse("You're voting on poll %s." % poll_id)
このエラーが発生しました:
UnboundLocalError at /polls/3/vote/
local variable 'poll_list' referenced before assignment
助けてください..なぜこのエラーが発生し続けるのかわかりません。ありがとう