Note that there are some explanatory texts on larger screens.

plurals
  1. POhow use json in javascript with django
    primarykey
    data
    text
    <p>I am new in django and python I'm trying use a json file in javascript using django</p> <p>The Javascript works fine when I use without django but when I do with django show me this error:</p> <pre><code>"TypeError: node is null" </code></pre> <p>I call the json this way:</p> <pre><code>d3.json("jsonfile.json", function(node) { .... } </code></pre> <p>I tried to put the json in the templates dir with the html file and with js file but didn´t work</p> <p><strong>Edit 1:</strong></p> <pre><code>d3.json("jsonfile.json", function(error, node) { .... } </code></pre> <p>Shows me : "TypeError: node is undefined"</p> <p>All the js are in the same dir:</p> <pre><code>&lt;script src="{{ STATIC_URL }}js/d3.v3.min.js" type= text/javascript&gt;&lt;/script&gt; &lt;script src="{{ STATIC_URL}}js/graph.js" type= "text/javascript"&gt;&lt;/script&gt; </code></pre> <p><strong>Edit2:</strong></p> <p>My JSON:</p> <pre><code>{ "coordinador":[ {"name":"ford","grupo":0}, {"name":"user1","grupo":1}, {"name":"user2","grupo":1}, {"name":"user3","grupo":1}, {"name":"car1","grupo":2}, {"name":"car2","grupo":2}, {"name":"car3","grupo":2}, {"name":"car4","grupo":2}, {"name":"car5","grupo":2} ], "links":[ {"source":1,"target":0,"origen":"user1","objetivo":"ford"}, {"source":2,"target":0,"origen":"user2","objetivo":"ford"}, {"source":3,"target":0,"origen":"user3","objetivo":"ford"}, {"source":4,"target":1,"origen":"car1","objetivo":"user1"}, {"source":5,"target":1,"origen":"car2","objetivo":"user1"}, {"source":6,"target":2,"origen":"car3","objetivo":"user2"}, {"source":7,"target":2,"origen":"car4","objetivo":"user2"}, {"source":8,"target":3,"origen":"car5","objetivo":"user3"} ] } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload