Comma as decimal field

276 views
Skip to first unread message

ydjango

unread,
Apr 5, 2012, 10:27:40 PM4/5/12
to Django users
What is best way to allow users to enter decimal either as "." or as
",'?
Currently if user enter "," django forms throw error.

I cannot change settings file based on user as same app serves users
worldwide.

Python_Junkie

unread,
Apr 5, 2012, 10:58:23 PM4/5/12
to django...@googlegroups.com
I assume that your problem is that when the data is posted , the ORM when submitting it to the database throws the eror.

You need to  place the posted value into a variable and use a python replace statement to replace the , with a period.

Not sure what type of validation that you are using.

Putting aside any sort of validation on the number.

new_number=request.post(variable_coming_in)

number=new_number.replace(" ,  " , "  . ")

Then the database won't complain
Reply all
Reply to author
Forward
0 new messages