Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing Django template variables into javascript in GAE
    primarykey
    data
    text
    <p>I'm trying to create a wordcloud with the Google's visualization sample:</p> <pre><code>&lt;link rel="stylesheet" type="text/css" href="http://visapi-gadgets.googlecode.com/svn/trunk/wordcloud/wc.css"/&gt; &lt;script type="text/javascript" src="http://visapi-gadgets.googlecode.com/svn/trunk/wordcloud/wc.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;div id="wcdiv"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; google.load("visualization", "1"); google.setOnLoadCallback(draw); function draw() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Text1'); data.addRows(160); {{datamade}} var outputDiv = document.getElementById('wcdiv'); var wc = new WordCloud(outputDiv); wc.draw(data, null); } &lt;/script&gt; </code></pre> <p>I'm creating {{datamade}} in my main.py file, then passing it as a template variable:</p> <pre><code> tweets1 = [] fetched = urlfetch.fetch("http://api.twitter.com/1/statuses/user_timeline.json?screen_name="+tweets.username+"&amp;count=200") statustext = json.loads(fetched.content) for tweetInfo in statustext: tweets1.append(tweetInfo["text"]) datamake = [] n = 1 for n in range(160): tweet = tweets1[n] datamake.append("data.setCell("+str(n)+", 0, '"+tweet+"');") datamade = '&lt;br&gt;'.join(datamake) content_values = { 'datamade':datamade, 'username':tweets.username, } </code></pre> <p>When I print the {{datamade}}, I see the correct Javascript code. And when I hardcode the values into my statuspage.html, the javascript executes correctly. But when I pass the variable directly into the javascript, the javascript does not execute properly.</p> <p>It my javascript executing prior to the template value is passed? Not sure how to adjust for this. I'd appreciate any advice. </p> <p>Disclaimer: I'm a total newb. </p> <p>Thank you! Jake</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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