I have a model Example with 3 fields.
class Example(models.Model):
name = models.CharField(max_length=200, null=False, blank=False)
number = models.CharField(max_length=200, null=False, blank=False)
address = models.CharField(max_length=200)`
I have a Post API (rest framework). This would have array of objects. I want to parse this array and store each object in my database. This is the Views.py
class PostExample(APIView):
def post(self, request, format=None):
example_records = request.POST["example_data"]
print example_records
Here "example_data" is the key and value will be an array. Example value:
[
{
"name": "test",
"address": "address",
"number": 123456789
},
{
...
}
]
I am unable to loop through "example_records". "example_records" prints the array but not able to get each object from this. How to achieve this ??
jsonmodule