title: How do I pass template values when doing a redirect?
body: <p>I use the blobstoreuploadhandler and hence must return a self.redirect but I need to pass values to my template. How can I do it? If I can't use template values then I suppose I can use session variables and I've included the beaker session library but I can't understand how to access the session variables in django template. Any idea how I should do it?</p>
  
  <p>I use default builtin django with google app engine and I can access session variables with a request handler but I don't understand how to do it in templates:</p>
  
  <pre><code>class Sessiontest(webapp.RequestHandler):
      def get(self):
          # Get the session object from the environ
          self.session = self.request.environ['beaker.session']
  
          # Check to see if a value is in the session
          if 'counter' in self.session:
              counter = self.session['counter'] + 1
              self.session['counter'] = counter
  
          else:
              self.session['counter'] = 1
              counter = 1
          self.session.save()
          self.response.out.write('counter: %d' % counter)
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Update/edit: My problem is almost exactly like this <a href="https://stackoverflow.com/questions/3887664/accessing-session-variable-in-django-template-with-google-app-engine-webapp-p">Accessing session variable in Django template with Google App Engine (Webapp) - Python</a> but with the library beaker instead of gaeutilities</p>
  
  <p>Update: Here's some of the code. we see that using HTTP GET to pass the values won't be very good since there's an anti-spam test that should hide the values:</p>
  
  <pre><code>def post(self, view):
      message = ''
      challenge = self.request.get('recaptcha_challenge_field').encode('utf-8')
      response  = self.request.get('recaptcha_response_field').encode('utf-8')
      remoteip  = os.environ['REMOTE_ADDR']
      cResponse = captcha.submit(
                   challenge,
                   response,
                   CAPTCHA_PRV_KEY,
                   remoteip)
      if cResponse.is_valid:
          isHuman=True
      else:#failed anti-spam test and can try again
          isHuman=False
          #Reprint the form
          import util
          template_values = {'isHuman':isHuman,'user' : users.get_current_user(),}
          template_values.update(dict(current_user=self.current_user, facebook_app_id=FACEBOOK_APP_ID))
          template_values.update(dict(capture=captcha.displayhtml(public_key = CAPTCHA_PUB_KEY, use_ssl = False, error = None)))
          path = os.path.join(os.path.dirname(__file__), 'market', 'market_insert.html')
          self.redirect("/ai") # Here the values aren't passed on and I must make a redirect
  </code></pre>