1👍
You have a typo:
console.log(data.notifiications[1].fields);
should be:
console.log(data.notifications[1].fields);
0👍
Okay, not sure what was wrong, but this works just fine
$.ajax({
url: '/notify/',
type:'GET',
dataType: 'json',
success: function (data) {
alert(data['notifications']);
var sed = JSON.parse(data['notifications'])
alert(sed[2].fields.choice_afl);
}
});
And in backend,as in EDIT2:
nots = serializers.serialize('json', Notification.objects.all(), fields=('whom','choice_afl'))
data = {
'notifications': nots
}
return Response(data)
- In the edit form of Django CRUD application the existing data is not showing correctly in the fields
- How do I add a field to a django-rest-framework serializer that isn't on my model?
- Create a list of choices automatically
Source:stackexchange.com