I am printing the output from my views function in Django using JsonResponse and want to correct the output and only include certain fields.How should I proceed?
The function is :
influencers = Influencer.objects.all()
influencer_data = serializers.serialize("json",influencers)
context = {
'influencer_data':influencer_data,
}
return JsonResponse(context)
The output/returned value is:
{"influencer_data": "[{\"model\": \"influencer_listings.influencer\", \"pk\": 7250, \"fields\": {\"full_name\": \"Be Yourself\", \"username\": \"tapasya_agnihotri\", \"photo\": \"\", \"email_id\": \"\", \"external_url\": \"\", \"location_city\": \"Kolkata\"
The output is like the one given above.However I want the output to be without the slashes.Also why is JsonResponse printing the slashes.