title: Decimal('12000') is not JSON serializable
body: <p>I have a Django instance running on Apache2.  One of my web pages is doing Ajax callbacks to Django.</p>
  
  <p>Most of the time, it works great, but sometime for a reason I can’t determine, it stops working with the following error from Django:</p>
  
  <p><strong>Decimal('12000') is not JSON serializable</strong> </p>
  
  <p>Once I received this error once, it stops working forever. The only solution I know is to restart Apache.</p>
  
  <p>The Python/Django is not changing, neither the data requested by the Ajax call. I never had this problem when I run my code on the Django web server.</p>
  
  <p>views.py:</p>
  
  <pre><code>@login_required
  def KPIInitTable(request):
      kpi_values = [ob.as_json() for ob in KPI.objects.all()]
      data = {'table_data' : kpi_values,
      'colHeaders': ['KPI', 'CityCategory', 'Type','January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
      'rowHeaders': 0,
      'KPIList': settings.TST_KPILIST,
      'TypeList': settings.TST_TYPELIST,
      'CityCategoryList': settings.TST_CITYCATEGORYLIST
      }
      response = HttpResponse(dumps(data, cls=DjangoJSONEncoder), mimetype='application/json')
      response['Cache-Control'] = 'no-cache'
      return response
  </code></pre>
  
  <p>Models.py:</p>
  
  <pre><code>from django.db import models
  
      class KPI(models.Model):
          name = models.CharField(max_length=50, null=True)
          CityCategory = models.CharField(max_length=50,  null=True)
          type = models.CharField(max_length=20, null=True)   
          Jan = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          Feb = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          Mar = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          Apr = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          May = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          Jun = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          Jul = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          Aug = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          Sep = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          Oct = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          Nov = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          Dec = models.DecimalField( max_digits=15, decimal_places=2, null=True)
          uniqueFields = ['name','CityCategory','type']
          class Meta:
              permissions = (
                  ("access_tst", "Access target setting tool."),
                  ("run_tst", "Compute new targets."),
                  ("validate_tst", "Validate and load new targets."),
          )
          def as_json(self):
              return {0: self.name, 1: self.CityCategory, 2: self.type, 3: self.Jan,4: self.Feb,5: self.Mar,6: self.Apr,7: self.May,8: self.Jun,9: self.Jul,10: self.Aug,11: self.Sep,12: self.Oct,13: self.Nov,14: self.Dec}
  </code></pre>
  
  <p>This value "12000" is indeed the first decimal value of the first row retruned by the database (SQLite).</p>
  
  <p>Any ideas?</p>
  
  <p>Thx,</p>