I am working with django and javascript, and I need to send a JSON of a dictionary to javascript. This needs to combine two different django queryset into a dictionary like object
I tried:
from itertools import chain
import json
checkin = Checkins.objects.get(checkinno=1)
checksins = (Checkins.objects.filter(checkinno=1).values('checkinno', 'date', 'time', 'consulted', 'closed'))
custid = checkin.hospitalid.cstid
checks = (customer.objects.filter(cstid=custid).values('name', 'age', 'gender', 'mobile', 'email', 'address'))
result_list = list(chain(checksins, checks))
print(result_list)
I get:
[{
'checkinno': 1,
'date': datetime.date(2018, 9, 10),
'time': '6:10 PM',
'consulted': 0,
'closed': 0
},
{
'name': 'Jeff',
'age': 5,
'gender': 'male',
'mobile': '000000',
'email': '', 'address': ''
}]
What I want:
[
'checkinno': 1,
'date': datetime.date(2018, 9, 10),
'time': '6:10 PM',
'consulted': 0,
'closed': 0,
'name': 'Jeff',
'age': 5,
'gender': 'male',
'mobile': '000000',
'email': '',
'address': ''
]