2👍
✅
Serializer is for serializing django objects, right now you have list of tuples instead, so django serializer won’t handle that.
If you want to connect this 2 lists together, you must get not only user_name
from your User_obj
, but also user_key
(id?) for connecting it with second model. If user_key
is actually an ForeignKey
, you can do this:
user_project_list = projectrunlog_object.values_list('user_key__user_name','project_run_date','project_run_status')
If not, you must handle it by yourself in python.
After creating list of dicts or tuples, you don’t have to run django serializer, normal json serializer will do the job:
json.dumps(list(user_project_list))
Source:stackexchange.com