I'm submitting a JSON to a django view with AJAX. The JSON looks like the following:
{
"code":"9910203040", // required
"name":"Abc", // required
"payments":[
{
"amount":300, // required
"name":"efg", // required,
"type": 2 // can be empty
},
{
"amount":100,
"name":"pqr",
"type": 3
}
]
}
The payments list can be of any size. How can I validate this in Django? Is it possible to use Django Forms to validate this? If it was Spring, I would create Request classes and use annotations on fields but can't figure out how to do this in Django.