I'm trying to get output result as an object but i'm getting result as a list.
My view:
def Expense_with_id(request, id):
details = ExSerializer(Cat.objects.filter(id=id).all(), many=True).data
return JsonResponse(details, safe=False)
Output:
[{
"id": 1,
"category": 1,
......
}]
I want my output to be :
Expected Output:
{
"id": 1,
"category": 1,
......
}
How can I achieve this with the current query.
many=Truegetinstead offilterthen removemany=True