docs: def display_queries(request, stats, queries):
      """
      Generate a HttpResponse of SQL queries for a profiling run.
  
      _stats_ should contain a pstats.Stats of a hotshot session.
      _queries_ should contain a list of SQL queries.
      """
      sort = request.REQUEST.get('sort_by', 'time')
      sort_buttons = RadioButtons('sort_by', sort, (
          ('order', 'by order'), ('time', 'time'), ('queries', 'query count')
      ))
      output = render_queries(queries, sort)
      output.reset()
      output = [html.escape(unicode(line)) for line in output.readlines()]
      response = HttpResponse(mimetype='text/html; charset=utf-8')
      response.content = (queries_template % {
          'sort_buttons': sort_buttons,
          'num_queries': len(queries),
          'queries': "".join(output),
          'rawqueries' : b64encode(cPickle.dumps(queries)),
          'rawstats': b64encode(pickle_stats(stats)),
          'url': request.path
      })
      return response