1#!/usr/bin/env python3
2
3"""Django helpers which create Response objects."""
4
5import json
6
7from django.http import HttpResponse
8
9from chart.api2.views import json_default_encoder
10
11
12def json_response(value):
13 """Convert `value` (a general Python structure) into a Django HTTP response.
14
15 Response contains `value` as a JSON structure.
16 """
17
18 # use the django 1.6 friendly content_type parameter instead of the old mimetype
19 return HttpResponse(json.dumps(value, separators=(',', ':'), default=json_default_encoder),
20 content_type='application/json')
21 # return HttpResponse(json.dumps(value, separators=(',', ':')), content_type='application/json')