1👍
While this is very old I found myself searching for this exact problem…
I found a way that works although I feel it is a bit unreliable
Javascript:
var rows = [];
$('.some_class').each(function(){
var id = $(this).attr('data-id');
var something = $(this).attr('data-something');
var item = {};
item["id"] = id;
item["something"] = something;
rows.push(JSON.stringify(item));
});
arr = rows.join("/");
ajax_req = $.ajax({
url: '../some_url/',
type: "POST",
data: {req_arr : arr},
});
views.py
items = request.POST.get('req_arr', None)
items = str(items).split("/")
for i in range(0, len(items)):
item = json.loads(items[i])
id = item['id']
something = item['something']
Source:stackexchange.com