Working Ninja
2016-11-03T20:05:28
PostgreSQL to JSON
import json
import psycopg2
from psycopg2.extras import RealDictCursor

cursor = conn.cursor(cursor_factory=RealDictCursor)
objects = cursor.fetchall()

print json.dumps(objects, indent=2)

# Django
#JsonResponse({'objects': objects})

Source: https://www.peterbe.com/plog/from-postgres-to-json-strings