1
views.py發送報告
def json(request):
defaultnumber = []
phoneinfo = PhoneInfo.objects.filter(user = user_id)
for phone in phoneinfo:
phone_no = {'id':some.id,
'name1':phone.name1,
'number1':phone.number1,
'name2':phone.name2,
'number2':phone.number2,
} }
defaultnumber.append(phone_no)
result = { 'phone':defaultnumber}
return HttpResponse(json.dumps(result), mimetype="application/json")
我需要將數據發送到JSON格式。
有幫助嗎? – alecxe