[Fixed]-Change json structure in Django

1👍

You’ll need to process the data; you can do whatever you like within the view function.

pos = Pos.objects.filter(id=1).values('lat', 'lon','id')
data = {"lats": [], "longs": []}
for p in pos:
    data["lats"].append(p['lat'])
    data["longs"].append(p['long'])
return JsonResponse({'position': data})

Leave a comment