Django: Ticket Queryhttps://code.djangoproject.com/query?id=2365%2C3324&order=priority
The Web framework for perfectionists with deadlines.en-USDjangohttps://www.djangoproject.com/s/img/site/hdr_logo.gifhttps://code.djangoproject.com/query?id=2365%2C3324&order=priority
Trac 1.0.4https://code.djangoproject.com/ticket/2365
https://code.djangoproject.com/ticket/2365#2365: [patch] models.FloatField should be renamedMon, 17 Jul 2006 08:27:21 GMTadurdin@…<p>
The behaviour of models.FloatField is inconsistent with its name. In the database backends it is implemented as a fixed-point NUMERIC column, and in Python it returns values of type decimal.Decimal -- which are compatible with each other, but are both incompatible with floating-point numbers. So it should be renamed to DecimalField or something similar that doesn't imply floating-point numbers.
</p>
Resultshttps://code.djangoproject.com/ticket/2365#changeloghttps://code.djangoproject.com/ticket/3324
https://code.djangoproject.com/ticket/3324#3324: FloatFields are converted to decimal and simplejson cannot serializeThu, 18 Jan 2007 20:08:19 GMTalex@…<p>
when serializing objects from a MySQL DB containing FloatFields to JSON, the float values are converted to Decimal objects, which are not understood by simplejson:
</p>
<pre class="wiki">
Traceback (most recent call last):
File "blah/test.py", line 18, in ?
test()
File "blah/test.py", line 16, in test
print serialize("json", Blah.objects.all())
File "/home/alex/source/svn/django/django/core/serializers/__init__.py", line 55, in serialize
s.serialize(queryset, **options)
File "/home/alex/source/svn/django/django/core/serializers/base.py", line 49, in serialize
self.end_serialization()
File "/home/alex/source/svn/django/django/core/serializers/json.py", line 19, in end_serialization
simplejson.dump(self.objects, self.stream, cls=DateTimeAwareJSONEncoder, **self.options)
File "/home/alex/source/svn/django/django/utils/simplejson/__init__.py", line 119, in dump
for chunk in iterable:
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py", line 220, in _iterencode
for chunk in self._iterencode_list(o, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py", line 143, in _iterencode_list
for chunk in self._iterencode(value, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py", line 223, in _iterencode
for chunk in self._iterencode_dict(o, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py", line 196, in _iterencode_dict
for chunk in self._iterencode(value, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py", line 223, in _iterencode
for chunk in self._iterencode_dict(o, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py", line 196, in _iterencode_dict
for chunk in self._iterencode(value, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py", line 231, in _iterencode
for chunk in self._iterencode_default(o, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py", line 237, in _iterencode_default
newobj = self.default(o)
File "/home/alex/source/svn/django/django/core/serializers/json.py", line 51, in default
return super(DateTimeAwareJSONEncoder, self).default(o)
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py", line 258, in default
raise TypeError("%r is not JSON serializable" % (o,))
TypeError: Decimal("9999999.99999999999999999999") is not JSON serializable
</pre>Resultshttps://code.djangoproject.com/ticket/3324#changelog