#23320: FloatField not converting values to float()
-------------------------------------+-------------------------------------
     Reporter:  pjrobertson          |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |                  Version:  1.7-rc-2
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:
     Severity:  Normal               |  Unreviewed
     Keywords:                       |      Needs documentation:  0
    Has patch:  0                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Old description:

> Apologies for creating an issue if this is the expected behaviour (FWIW
> there were no ideas on IRC):
>
> Is the behaviour outlined in this snippet expected:
> https://dpaste.de/BAck
>
> I'd have expected the FloatField to convert values to a float in the
> return object as well (I can verify that the `to_python` method is being
> run, because the number is saved to the database correctly.
>

> Is the recommended way of solving this to subclass FloatField and use?
>

> {{{
> class MyFloatField(with_metaclass(models.SubBaseField,
> models.FloadField)):
>    ...
> }}}

New description:

 Apologies for creating an issue if this is the expected behaviour (FWIW
 there were no ideas on IRC):

 Is the behaviour outlined in this snippet expected:
 {{{#!python
 # models.py
 from django.db import models

 class Fl(models.Model):

     float = models.FloatField()


 # ./manage.py shell
 >>> from models import Fl
 >>> a = Fl.objects.create(float=' 1.0 ')
 >>> a
 <Fl: Fl object>
 >>> a.float
 ' 1.0 '
 }}}

 I'd have expected the FloatField to convert values to a float in the
 return object as well (I can verify that the `to_python` method is being
 run, because the number is saved to the database correctly.


 Is the recommended way of solving this to subclass FloatField and use?


 {{{
 class MyFloatField(with_metaclass(models.SubBaseField,
 models.FloadField)):
    ...
 }}}

--

Comment (by bmispelon):

 (pulled in the code from dpaste so that this report still makes sense in 4
 weeks after the link expires)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/23320#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.1ad5bced7be6eda705f8ee2ea27d1ad6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to