As we know, Django=3 is supporting JSONField . I am trying to save JSON data in my Django Project using JavaScript, i have take data in a input field which looks like:
[{"id":1,"Name":"Antenna","Pieces":"","Weight":"","Weight Types":"","Quantity":"12",
"Cargo Charge":"12","Customs Charge":"12"},
{"id":2,"Name":"Soap","Pieces":"12","Weight":"12","Weight Types":"","Quantity":"",
"Cargo Charge":"12","Customs Charge":"12"}]
From the input field I save the data to MySql database using .
product_list = self.request.POST['product_list_json']
Hence, product_list_json
is the name of the inout field.
But the saving data is given different view, the saved data look like:
"[{\"id\":1,\"Name\":\"Antenna\",\"Pieces\":\"\",\"Weight\":\"\",\"Weight Types\":\"\",
\"Quantity\":\"12\",\"Cargo Charge\":\"12\",\"Customs Charge\":\"12\"},
{\"id\":2,\"Name\":\"Soap\",\"Pieces\":\"12\",\"Weight\":\"12\",\"Weight Types\":\"\",
\"Quantity\":\"\",\"Cargo Charge\":\"12\",\"Customs Charge\":\"12\"}]"
The problem is that, data is saving with additional " \ " . What can i do to solve this?