title: Passing objects from Django to Javascript DOM
body: <p>I'm trying to pass a Query Set from Django to a template with javascript.</p>
  
  <p>I've tried different approaches to solve this:</p>
  
  <p><strong>1. Normal Approach - Javascript gets all messed up with trying to parse the object because of the nomenclature [ &amp;gt Object:ID &amp;lt, &amp;gt Object:ID &amp;lt,... ]</strong></p>
  
  <p>Django View</p>
  
  <pre><code>django_list = list(Some_Object.objects.all())
  </code></pre>
  
  <p>Template HTML + JS</p>
  
  <pre><code>&lt;script type="text/javascript" &gt;
      var js_list = {{django_list}};
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>2. JSON Approach - Django fails on converting the object list to a json string 
  is not JSON serializable</strong></p>
  
  <p>Django View</p>
  
  <pre><code>django_list = list(Some_Object.objects.all())
  json_list = simplejson.dumps(django_list)
  </code></pre>
  
  <p>Template HTML + JS</p>
  
  <pre><code>&lt;script type="text/javascript" &gt;
      var js_list = {{json_list}};
  &lt;/script&gt;
  </code></pre>
  
  <p>So, I need some help here :)</p>
  
  <p>Any one has any suggestion / solution?</p>
  
  <p>Thanks!</p>