JSON data

12 views
Skip to first unread message

HJ

unread,
May 24, 2020, 11:46:46 AM5/24/20
to Django users
hello guys hope you are doing well 

I am trying to make a highchart but I found a problem in the view function so my chart doesn't show becuase of that 

view function 

def jsonDepend(request):
 dataset = mail_item_countries_depend.objects.all().values('exped','destin','count')
 data = list(dataset)

  return JsonResponse(data, safe=False)


my views function show something like this : [{"exped": "MA", "destin": "AL", "count": 2}, {"exped": "MA", "destin": "BS", "count": 1}]  

how can I store it like that : [["MA", "AL",  2], ["MA", "BS", 1]] 

Saurabh Adhikary

unread,
May 24, 2020, 2:17:03 PM5/24/20
to Django users
data =  [{"exped": "MA", "destin": "AL", "count": 2}, {"exped": "MA", "destin": "BS", "count": 1}] 
mylist = []
for a in data :
    mylist.append([a['exped'],a['destin'],a['count']])
Reply all
Reply to author
Forward
0 new messages