On 5/1/07, Chris Brand <[EMAIL PROTECTED]> wrote:
>
> I've got a model that includes FloatFields as well as IntegerFields and
> CharFields.
> When I access the CharFields, I get strings. When I access the
> IntegerFields, I get integers, but when I want to use the Floatfields, I
> always have to add float() to convert the string to an actual float. Not
> that big a deal, but I always forget it first time around, and it just
> doesn't feel right.
>
> Here's a brief test :
> >>> c = Camp.objects.get(pk=1)
> >>> c.min_age
> '17.0'
> >>> a = c.min_age
> >>> type(a)
> <type 'str'>
>
> And here's the corresponding field definition :
>     min_age = models.FloatField("Minimum age", max_digits=3,
> decimal_places=1, default=0, validator_list=[age_validator])
>
> Why is this ?
>
> I'm using 0.96 with a MySQL backend.

What version of Python are you using? I *think* FloatFields are
returned as Python Decimal objects, which don't exist before
Python-2.4, which means you would then get a string from MySQLdb. We
might need a fix for Django on Python-2.3 to work around this.

-- 
Patriotism means to stand by the country. It does
not mean to stand by the president. -- T. Roosevelt

This message has been scanned for memes and
dangerous content by MindScanner, and is
believed to be unclean.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to