I am trying to create some json that will render a highchart graph with python/django.
here is what my view looks like so far:
class LineHighChart(object):
title = {}
def weight_graph(request):
print 'weight graph'
highchart = LineHighChart()
title = {
'title': {
'text': 'Weight Chart',
'x': -20
}
}
highchart.title = title
print highchart
return JsonResponse(highchart, safe=False)
This prints:
<shared.linehighchart.LineHighChart object at 0x1038a6890>
I then get the error:
TypeError: <shared.linehighchart.LineHighChart object at 0x1038a6890> is not JSON serializable
From the highcharts example, this needs to be embedded in a highcharts object like this:
highcharts({
title: {
text: 'Monthly Average Temperature',
x: -20 //center
},
How do I make my highcharts object look like the highcharts example?