title: django testing response.context TypeError: 'NoneType' object is not subscriptable
body: <p>I want to test this view:</p>
  
  <pre><code>def register(request):
      """
      handle user registration
      code variable is for testing purposes
      """
      if request.method== 'GET':
          form = RegisterForm(auto_id=False)
          code = 1
          return render_to_response('register_home.html',locals(),context_instance=RequestContext(request))
      elif request.method == 'POST':
          form = RegisterForm(request.POST)
          if form.is_valid():
              password = form.cleaned_data['password']
              password_confirmation = form.cleaned_data['password_confirmation']
              if password == password_confirmation:
              #if True:
                  login = form.cleaned_data['login']
                  email = form.cleaned_data['email']
                  newsletter = form.cleaned_data['newsletter']
                  key = register_user(login,email,password,newsletter)
                  if key:             
                      #send email
                      send_mail("Dziękujemy za rejestrację"," Klucz aktywacyjny to " + key,settings.EMAIL_HOST_USER,[email])
                      request.session['email'] = email
                      return redirect(register_success)
                  else:
                      code = 4
                      error = "Login /email are taken"
                      return render_to_response('register_home.html',locals(),context_instance=RequestContext(request))
              else:
                  code = 3
                  error  = "invalid password"
                  return render_to_response('register_home.html',locals(),context_instance=RequestContext(request))
          else:
              code = 2
              return render_to_response('register_home.html',locals(),context_instance=RequestContext(request))
  </code></pre>
  
  <p>And here is my part of my test:</p>
  
  <pre><code>def test_valid_credentials(self):
          #now try to register valid user
          data = {'login':'test','password':'zaq12wsx','password_confirmation':'zaq12wsx','terms':True,'newsletter':True,'email':'test@test.com'}
          response = self.c.post(reverse('register'),data)
          #our user should be registred
          self.assertEquals(302, response.status_code,'We dont have benn redirected')
          self.assertEqual(len(mail.outbox), 1,'No activation email was sent')
          #clen email box
          mail.outbox = []
          #now try to add anotheer user with the same data
          response = self.c.post(reverse('register'),data)
          #template should be rendered with error message about used login and email
          self.assertEqual(response.context['code'],4)
  </code></pre>
  
  <p>And here is the error that I got:
  , </p>
  
  <pre><code>in test_valid_credentials
      self.assertEqual(response.context['code'],4)
  TypeError: 'NoneType' object is not subscriptable
  </code></pre>
  
  <p>I tried it with get method and it works perfectly. Just with post it don't want to work.What am I doing wrong?Best regards</p>