I am working with a django model which stores currency values as integers. i.e. GBP22.35 gets stored as 2235.
When that model gets rendered as a form, I need to be able to associate a widget with that integer field so can be edited as though it were a float value (i.e. to two decimal places - 22.35) and is validated as such. form.save() then needs to save the native integer value to the db.
I've tried creating a custom FormField/Widget pair which involves dividing by 100 in the widgets render and multiplying back up in the fields to_python method, but it all goes awry if there is an error on the form. The widget keeps re-dividing the value.
I realise this could be avoided by using float/decimal model fields but that is not an option in this case.
Is this something people have done before? Any pointers? Thanks.
FloatField?? Ok, I see you don't have that option.FloatFieldis never an acceptable option.