Decimal fields have landed on trunk: rename your FloatFields

19 views
Skip to first unread message

Malcolm Tredinnick

unread,
May 20, 2007, 9:43:48 PM5/20/07
to django...@googlegroups.com
I don't want to get into the habit of announcing every single change to
trunk, but let's make a pre-emptive strike, just this once...

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 Moffitt

unread,
May 20, 2007, 10:29:29 PM5/20/07
to django...@googlegroups.com
This is great news. Thanks for all your work in getting this done!

-Chris

waylan

unread,
May 21, 2007, 9:22:10 AM5/21/07
to Django users
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 the DecimalField section header (line 188??).

[1]: http://www.djangoproject.com/documentation/model-api/#decimalfield


Malcolm Tredinnick

unread,
May 21, 2007, 5:39:39 PM5/21/07
to django...@googlegroups.com
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 the DecimalField section header (line 188??).

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


Uros Trebec

unread,
May 21, 2007, 9:37:27 PM5/21/07
to Django users
Hi guys!

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??).

Bram - Smartelectronix

unread,
May 22, 2007, 12:13:58 PM5/22/07
to django...@googlegroups.com
Hey,

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

Malcolm Tredinnick

unread,
May 22, 2007, 6:09:05 PM5/22/07
to django...@googlegroups.com

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


Bram - Smartelectronix

unread,
May 24, 2007, 7:13:53 AM5/24/07
to django...@googlegroups.com
Hello 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

Malcolm Tredinnick

unread,
May 24, 2007, 7:46:43 AM5/24/07
to django...@googlegroups.com

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


Reply all
Reply to author
Forward
0 new messages