title: django session serializer help choosing between pickle/json
body: <p>I'm using django 1.6, in which the default session serializer is json. I use db as my storage engine for sessions.<br>
  I've changed this setting so now I use pickle. 
  Now, after reading that: <a href="http://www.benfrederickson.com/2014/02/12/dont-pickle-your-data.html" rel="nofollow">http://www.benfrederickson.com/2014/02/12/dont-pickle-your-data.html</a><br>
  I was surprised about the huge differences in terms of speed.<br>
  I'm aware of the security issues of pickle, but they are less concern for now, as I dont serialize data that come from users, and my website isn't that famous anyway.  </p>
  
  <p>I've checked my code and what I store in session are these types:<br>
  strings (ok for json)<br>
  booleans (ok for json)<br>
  datetime (not ok for json, but I could switch to string and parse it when needed)<br>
  render object(HttpRespone. not ok for json).<br>
  So as you can see I could move to json if I could just solve the last type that I store.
  Basically the thing is this:<br>
  I execute an SQL query to generate some page. This page contains an iframe (google maps), which needs the same SQL output. So I don't want to perform the same SQL twice, so I just 'render' the two pages in the same view,using the same context and query output, and when I load the iframe I pull the already generated page from the session.<br>
  How can I avoid doing that? What would be a solution to generate to pages in the same view?</p>
  
  <p><strong>EDIT</strong>:<br>
  This is the case explained.<br>
  index.html contains an <code>&lt;iframe src='/map/'&gt;</code>  </p>
  
  <p>to generate index.html, the view is:</p>
  
  <pre><code>def index(request):
      output = sql_query
      return render_to_response('index.html', {'data':output})
  </code></pre>
  
  <p>Since index.html has an iframe in it, another GET request will be sent, will reach to this view:  </p>
  
  <pre><code>def map(request):
      # Here I need the same sql output I had from the index view.
      # I don't want to perform this sql again.
      # So what I did is to create the page in index view, store it in the session,
      # and just return the page from the session. like this:
      return request.session['rendered_page_from_index_view']
  </code></pre>
  
  <p>That's why I changed to pickle serializer. Besides that I could use json. How can I avoid storing this page in the session, without doing the same sql twice?<br>
  I hope I made my point clear.</p>