2π
β
x
in your loop is an index of the array, so you want: alert(data[x].model)
see for..in loop
Also, if youβre using Django 1.7+, please use JsonResponse
from django.http import JsonResponse
...
else:
objs = Tender.objects.all()[:4]
return JsonResponse(objs)
π€ben432rew
0π
[ //<- Array
{ //<- Object
"model": "Register.tender",
"pk": 1,
"fields": { //<- Object
"Name": "First",
"Kind": "Public Trend",
"Category": 1,
"Description": "my first bid ",
"Created_on": null,
"Modified": null,
"Active": true,
"Size": "S",
"Ministry": 1
}
}
]
Accessing
var Obj = data[0];
Obj.model;
Obj.pk;
Obj.fields.Name
Obj.fields...
OR
data[x].model;
data[x].pk;
data[x].fields.Name
data[x].fields...
π€user2411670
- [Answered ]-How do I sort the queryset by a property's property? django
- [Answered ]-Match file path in url regex
Source:stackexchange.com