Sorry for my English. I have some data from another server, but I need output this data like JSON.
if i print response in console:
{
'responseStatus': {
'status': [],
},
'modelYear': [
1981,
1982
]
}
but, if i return this response like HttpResponse
i have error
AttributeError: 'str' object has no attribute '_meta'
this my code:
data = serializers.serialize('json', response, ensure_ascii=False)
return HttpResponse(data, content_type="application/json")
UPD:
i did like this
from django.http import JsonResponse
def some_view(request):
...
return JsonResponse(response, safe=False)
but have error:
Object of type 'ModelYears' is not JSON serializable
UPD:
I did like this
import json
from django.http import JsonResponse
def some_view(request):
...
return JsonResponse(json.loads(response))
but have error
the JSON object must be str, bytes or bytearray, not 'ModelYears'