I am facing the same problem and I solved the problem in a more understandable way.
Problem:
If I send below JSON to the server, the boolean fields come as test ("true", "false"), and I should have access to catalogues as request.POST.getlist("catalogues[]") . Also I cannot simplify form validation.
var data = { "name": "foo", "catalogues": [1,2,3], "is_active": false } $.post(url, data, doSomething);
Django Request Handler:
def post(self, request, **kwargs): catalogues = request.POST.getlist('catalogues[]')
Decision
I get rid of these problems by sending json data as string and converting the data back to json on the server side.
var reqData = JSON.stringify({"data": data})
Django Request Handler:
def post(self, request, **kwargs): data = json.loads(request.POST.get('data'))
Now I can do form validation, and the code is cleaner :)
source share