Re: Override DECIMAL_SEPARATOR in certain cases?
Seems weird that no one have had this problem before... Maybe no one is using any other locale than en-us? Anyway, I solved it by making a custom template filter called "dotify", which if it gets a floating point number, converts it to a string, and replaces all commas with "dots": def dotify(value): if isinstance(value, basestring): return string.replace(',', '.') elif isinstance(value, float): return ('%f' % value).replace(',', '.') else: return value dotify = register.filter(dotify) / Joachim -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Override DECIMAL_SEPARATOR in certain cases?
In my application I have LANGUAGE_CODE set to 'sv-SE', which uses comma as decimal separator. When using a model field containing a floating point number as argument to a Javascript function, or when sending the number to an external site (in my case as coordinates to get a static map from Google Maps), the model field should not be localized. Is there a known way to change the localization for number formating for certain cases? And no, the DECIMAL_SEPARATOR setting in the project settings does not seem to be used anywhere, and the decimal fields should be localized when showing the number to a user. I'm using the 1.3 alpha release of Django. Regards / Joachim -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.