title: Passing a cursor to a Serializer in django-rest-framework?
body: <p>I'm using Django 1.8 with django-rest-framework v3.2.2. I have a query that involves raw SQL:</p>
  
  <pre><code>@api_view(['GET'])
  def total_spending(request, format=None):
      code = request.query_params.get('code', None)
      query = 'SELECT * FROM vw_presentation_summary WHERE code=%s"
      cursor = connection.cursor()
      cursor.execute(query, tuple([code]))
      cursor.close()
  </code></pre>
  
  <p>My question is how to take this cursor and turn it into a data object that I can pass to django-rest-framework's <code>Response</code>. </p>
  
  <p>Right now I'm doing it manually, which works OK:</p>
  
  <pre><code>def dictfetchall(cursor):
      "Returns all rows from a cursor as a dict"
      desc = cursor.description
      return [
          dict(zip([col[0] for col in desc], row))
          for row in cursor.fetchall()
      ]
  
  def total_spending(request, format=None):
      ...
      return Response(dictfetchall(cursor))
  </code></pre>
  
  <p>But would it be better to use a Serializer somehow? I'm not clear if Serializers do anything useful other than define the fields you want to return. </p>