title: QuerySet is not JSON Serializable Django
body: <p>newbie programming here. I have a model with many rows and I would like to pass each row to javascript. </p>
  
  <p><strong>First attempt:</strong></p>
  
  <p>Views.py</p>
  
  <pre><code>events = Events.objects.filter(user_id=user_id) // filter by user_id
  context = {
              "email": request.user.email,
              "login": True,
              "objects": events,
          }
  return render(request, 'fullcalendar/index.html', context)
  </code></pre>
  
  <p><code>Events</code> is the name of the table and I stored each row in <code>events</code>. Passed that into a dict called <code>context</code> which is then passed to my template. Then from my template I was able to do something like this:</p>
  
  <pre><code>{% for object in objects %}
      &lt;p&gt;event.column_name&lt;/p&gt;
  {% endfor %}
  </code></pre>
  
  <p>and that would work fine, however I can't do that in the javascript section.</p>
  
  <pre><code>{% for object in objects %}
      var date = object.date // assuming object has a column named date
  {% endfor %}
  </code></pre>
  
  <p><strong>Second Attempt</strong></p>
  
  <p>So I did some research and decided to use json.</p>
  
  <p>In Views.py I made the following change:</p>
  
  <pre><code>return render(request, 'fullcalendar/index.html', {"obj_as_json": simplejson.dumps(context)})
  </code></pre>
  
  <p>and from this I hoped to do this:</p>
  
  <pre><code>var objects = {{ obj_as_json }}
  
  for object in objects 
      //Do some stuff
  </code></pre>
  
  <p>But I got the error <code>QuerySet is not JSON Serializable Django</code>. So I looked up how to serialize objects and made the following change:</p>
  
  <pre><code>data = serializers.serialize('json', events.objects.all())
  </code></pre>
  
  <p>But I got following error: <code>'QuerySet' object has no attribute 'objects'</code></p>
  
  <p>Man, theres got to be a easier way to do what I want to do. Any ideas?</p>