In my Django apllication, I need to take fields from two different tables (models.py classes), lets say username form one table and other information from some other table. this fields will be in the from of list since I use values_list to retrieve them. But the thing is I need to concate this two list and use serializer mechanism so that further I can prepare a json out of it. The Django's default serializer does not support this. Is there any other alternative for django serilizer that supports different types of objects in a list? sample code:
Fields from projectrunlog table in models.py
user_project_list = projectrunlog_object.values_list('user_key','project_run_date','project_run_status')
Fields from user info table in models.py
user_name = User_obj.values_list('user_name')
Not sure, but want to try something like this and make a json out of field and fields2
fields = serializers.serialize('json', list(projectrunlog_object), fields = ('user_key','project_run_date','project_run_status'))
fields2 = serializers.serialize('json', list(User_obj), fields = ('user_name'))
So, in my json, I want user_name as well along with other four fields, and should work seamlessly, without knowing that user_name comes from different table. kindly suggest what to do.
As suggested by GwynBleidD, I cannot do :json.dumps(list(user_project_list)) Because here, user key is actually a UUID field. It is showing error as "UUId is not JSON serializable". I am using Django 1.8 wherein UUID implementation is default. Any solution??