I had generated json with my model objects and sended responce to the template.
then i wanted to process json getting fields of my model with javascript.
Python code is like that:
return json_serializer.serialize(queryset, ensure_ascii=False)
js in template is here:
function my_js_callback(data){
alert(data) //1
item=data[0]
alert(item) //2
}
1 – gives me [object Object], [object Object],…
2 – gives [object Object]
And this:
alert(item['title'])
alert(item.title)
alert(item["title"])
All give me errors. How can i get my title?
It was my mistake.
My JSON was like several levels dict and i couldn’t find my field beacuse it was in dictionary named fields in the JSON object first level dictionary.
Now it is okay: