Just starting out with django.
Currently working on using a json in my javascript:
views.py:
a = ModelA.objects.filter(status = 'A').values('name', 'id', 'pos', 'status')
b = ModelA.objects.filter(status = 'B').values('name', 'id', 'pos', 'status')
data = {
'a': a,
'b': b,
}
return HttpResponse(simplejson.dumps(data), mimetype='application/json')
Exploring nodeshot, where I found a function to fetch json data:
$.getJSON(nodeshot.url.index+"nodes.json", function(data) {
nodeshot.nodes = data;
});
However, when trying this:
var data = nodeshot.nodes[status]; //'a' for example
for(var node in data) {
...
}
Upon using alert(node)
, the output is:
0
1
remove
The unexpected value "remove" in the loop results raises questions. This loop should only iterate twice.