I am trying to make a json array in django but I am getting error -
In order to allow non-dict objects to be serialized set the safe parameter to False
and my views.py -
def wall_copy(request):
if True:
posts = user_post.objects.order_by('id')[:20].reverse()
return JsonResponse(posts)
Basically user_post is a model a posts is the object of top 20 saved data. I want to send a json array but I am unable to convert posts into a json array. I also tried serializers but it didnt helped.
I am stuck help me please.
Thanks in advance.