If you use FloatField in your models and follow trunk, you are really,
really going to want to read the BackwardsIncompatibleChanges page in
the wiki before using [5302] or later.
This is the long-awaited commit of a true decimal field type (fixed
precision in the database and decimal type in Python) and includes, as a
bonus, a real FloatField (stored as a double precision field in the
database).
It works with Python 2.3 as well and I've tested it with every database
I have access to on 2.3, 2.4 and 2.5. So hopefully the only bugs should
be easy to fix things in edge cases.
Regards,
Malcolm
-Chris
Btw, it looks like there is a small bug in the docs [1]. Just add a
couple tildes to the DecimalField section header (line 188??).
[1]: http://www.djangoproject.com/documentation/model-api/#decimalfield
Damn. We always screw that one up. It's an easy mistake to make when
editing titles and it's an error that rst2html doesn't warn about for
some reason. Difficult to even catch it in proof reading.
Looks like Adrian's fixed it whilst I've been asleep anyway.
Thanks,
Malcolm
I can't believe how fast are you developing Django! I had a 2 days old
checkout and was looking at current model documentation... and the
validation kept saying "'module' object has no attribute
'DecimalField'".
I was ready to give up and take a nap to clear my mind when I thought
I should check the Groups... and here it is, a change one day old!
Congrats on to all developers for progress this fast and to all users
that can keep up with all the changes :)
Best regards,
Uros Trebec
FullHistory Branch
On May 21, 11:39 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Mon, 2007-05-21 at 13:22 +0000, waylan wrote:
> > Mmm, good things come to those who wait. It's nice to see this finally
> > come through. Thanks for all the hard work.
>
> > Btw, it looks like there is a small bug in the docs [1]. Just add a
> > couple tildes to theDecimalFieldsection header (line 188??).
Malcolm Tredinnick wrote:
<snip>
> It works with Python 2.3 as well and I've tested it with every database
> I have access to on 2.3, 2.4 and 2.5. So hopefully the only bugs should
> be easy to fix things in edge cases.
Eek, I might have found one:
TypeError at /my/url/
Decimal("0.0") is not JSON serializable
- bram
Pleasee file a ticket with a small, self-contained, repeatable example
that demonstrates the problem. Reporting ticket son the mailing list is
a good way to have them forgotten about.
I did test JSON serialisation of decimals, so it doesn't fail always.
There's a change in core/serializers/json.py for exactly that purpose.
So there's something special about your setup.
Regards,
Malcolm
Malcolm Tredinnick wrote:
> Pleasee file a ticket with a small, self-contained, repeatable example
> that demonstrates the problem. Reporting ticket son the mailing list is
> a good way to have them forgotten about.
>
> I did test JSON serialisation of decimals, so it doesn't fail always.
> There's a change in core/serializers/json.py for exactly that purpose.
> So there's something special about your setup.
The problem is when using simplejson out of the box (and not using the
JSONSerializer in django):
simplejson.dump( [ mymodel.my_decimal_field ] )
doesn't work, although it did work before on the float field. Casting it
to float works again:
simplejson.dump( [ float(mymodel.my_decimal_field) ] )
I'm not sure if it's worth ticketing this...
- bram
There's no bug here.
Firstly, it's a "problem" with simplejson, not with Django. It would be
bad policy for us to make any changes to simplejson. We just include a
copy of the upstream simplejson source.
It's not even really a problem with simplejson, since Bob Ippolito has
designed it very well to make it easy to extend as you might wish.
That's exactly how we handle the problem in Django and how you should
handle it if you are using simplejson directly for your own purposes.
Regards,
Malcolm