On Apr 17, 9:04 am, Knut Nesheim <knut.nesh...@mtab.se> wrote:
> Hi all,
>
> I have a model with several FloatFields. Based on this, ModelForm  
> creates some form.FloatFields.These fields require the user to type  
> '3.2' instead of '3,2', which is the custom here(Sweden). We need to  
> allow the comma somehow, for obvious usability reasons.
>
> My first thought was to write a custom clean method on the form, which  
> would do a string replace, but this isn't working. The FloatFields  
> clean method is run before any custom method. If there's a comma in  
> the field, that method will raise an exception and my custom method  
> never gets called.
>
> Any ideas for a solution would be welcome.

You can subclass a RegexField and return a float in clean.
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to