title: TypeError: object is not JSON serializable in DJango 1.8 Python 3.4
body: <p>I'm using DJango 1.8 and Python 3.4</p>
  
  <p>When the below view is being ran, Django throws Type Error - Object is not JSON Serializable</p>
  
  <p><strong>Views.py</strong></p>
  
  <pre><code>from django.http import HttpRequest,HttpResponse
  from django.http import JsonResponse
  from json import dumps
  
  def get_stats(request):
      if request.method == "POST":
          srch_dropV = request.POST['srch_dropAJ']
      else:
          srch_dropV = ''
      if(srch_dropV == 'Green'):
          students = GreenBased.objects.all()
      if(srch_dropV == 'Yellow'):
          students = YellowBased.objects.all()
      response_data = {}
      try:
          response_data['result'] = 'Success'
          response_data['message'] = list(students)
      except:
          response_data['result'] = 'Ouch!'
          response_data['message'] = 'Script has not ran correctly'
      return HttpResponse(JsonResponse(response_data), content_type="application/json")
  </code></pre>
  
  <p>I'm trying to read couple of rows from mysql database and display it on the html file, I'm facing below error message when above view is being ran </p>
  
  <pre><code>TypeError: YellowBased: YelloBased object is not JSON serializable
  </code></pre>
  
  <p>In HTML Page, I have a drop down list.. based on the option that is selected, my Ajax would return me the records that were fetched from mysql table.</p>
  
  <p><strong>Models.py</strong></p>
  
  <pre><code>class GreenBased(models.Model):
      NumOfStudents = models.CharField(max_length=300,blank=True)
      Green = models.CharField(max_length=300,blank=True)
      class Meta:
          managed = False
          db_table = "GreenStats"
  
  class YelloBased(models.Model):
      NumOfStudents = models.CharField(max_length=300,blank=True)
      Yellow = models.CharField(max_length=300,blank=True)
      class Meta:
          managed = False
          db_table = "YellowStats"
  </code></pre>
  
  <p>GreenStats and YellowStats tables contains only 2*2 rows in mysql
  Can someone please help me to identify this issue ?</p>