from django.views.decorators.http import require_POST
import json
@require_POST
def api_sample(request):
data = json.loads(request.POST.get('targets'))
print(data) # {'key1': [[1, 2, 3], [65, 3, 11], ...]}
Python
$.ajax({
type: 'POST',
url: '/api_sample',
dataType: 'json',
data: {
targets:JSON.stringify({"key1":[[1, 2, 3], [11, 22, 33]]})
},
success: (res)=>{
console.log(res)
},
error: (error)=>{
console.log(error)
}
})
Jquery