[Answered ]-Serializing data results from query with select_related into json

2👍

views.py

 from django.utils import simplejson

 def convert_to_json():
   uinfo = Userinfo.objects.filter(userId_id__in=inner_qs).values('userId__username', 'userImg', 'says', 'userId__first_name', 'city')
   lusers = ValuesQuerySetToDict(users)
   response = simplejson.dumps(lusers)
   return response

 def ValuesQuerySetToDict(vqs):
   return [item for item in vqs]
👤Niya

Leave a comment