title: Python Django Session
body: <p>I'm new with django. </p>
  
  <p>I have this poll app, and I want to limit the voters with 1 vote per session per poll. Example:</p>
  
  <p>poll #1</p>
  
  <p>poll #2</p>
  
  <p>when I will vote to poll #1, after it I can't vote for poll #1 but I can vote for poll #2.</p>
  
  <p>so i decided to place the poll id into a list then check if its in there.</p>
  
  <pre><code>poll_list = [] #declare the poll_list variable
  
  @login_required
  @never_cache
  def vote(request, poll_id):
      global poll_list #declare it as global
      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 render_to_response('polls/detail.html', {
              'poll': p,
              'error_message': "You didn't select a choice.",
          }, context_instance=RequestContext(request))
      else:
          if poll_id in request.session['has_voted']: #here is the checking happens
              return HttpResponse("You've already voted.")
  
          selected_choice.votes += 1
          selected_choice.save()
  
          poll_list.append(poll_id) #i append the poll_id
          request.session['has_voted'] = poll_list #pass to a session
          return HttpResponseRedirect(reverse('poll_results', args=(p.id,)))
      return HttpResponse("You're voting on poll %s." % poll_id) 
  </code></pre>
  
  <p>I got an error:</p>
  
  <pre><code>KeyError at /polls/3/vote/
  'has_voted'
  </code></pre>
  
  <p>this error will prompt after I click the vote button</p>
  
  <p>anyone who can help me with this?</p>
  
  <p>Thanks,
  Justin</p>