I have single object filtered as below.
backTest= BackTest.objects.first()
I would like to return this object as jsonResponse.
data = dumps(backTest)
return JsonResponse(data)
I got error message as below.
Object of type BackTest is not JSON serializable
Any advice or guidance on this would be greatly appreciated, Thanks.
CodePudding user response:
For Django 1.7 ,use this :
from django.http import JsonResponse
backTest= BackTest.objects.first()
return JsonResponse({'backtest':backTest})
