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)
- [Answer]-Django: Make a query inside a class
- [Answer]-How can I call all items in a list item?
- [Answer]-How to change the name of the document=True field of Haystack in Django?
- [Answer]-How to download all bucket files using gsutil with django-gae app
- [Answer]-Django.db.migrations.graph.CircularDependencyError in Django 1.7.1
Source:stackexchange.com