[Answer]-When try to convert django dict to json object it says "'str' object has no attribute '_meta'"

1👍

That is a common error with serializers.serialize

You’re trying to serialize an object that is not a model queryset.

Your data object is a dictionary, so you don’t need to serialize it, just return that dict with json dump.

0👍

responce_data['allusers']=allusers
responce_data['dept_data']=dept_data
responce_data['surey_data']=surey_data
responce_data['survey_id']=survey_id
data = serializers.serialize('json', responce_data)

Here your call passing dict response_data to serializer, rather you should pass list of objects that you want to serialize.

So create list of objects and also do not specify string survey_id in the list to serialize.

Update your code to

dept_data=list(SuUserDepartment.objects.filter(org=request.session['user_login_data']['org']))

allusers=list(SuUser.objects.filter(dept_id=dept))
responce_data = [ surey_data, ] + dept_data + allusers
data = serializers.serialize('json', responce_data)
👤Rohan

Leave a comment