On Fri, 2007-07-06 at 13:25 +0200, Thomas Güttler wrote: > Hi, > > I read the source of the newforms module, but there > seems no easy way to get i18n for dates and decimals. [...] > > The constructor of models.DecimalField could take the > decimal separator as keyword argument and give his Input > Widget this method. Of course the to_python() method > must be changed, too.
We don't want to be putting presentation-layer information like this into model fields. The presentation form is locale dependent, whereas model fields store the concrete piece of data (the decimal number represented by 1.23 in the C locale is always the same number, not matter what locale you are in). What we do need to do (prior to 1.0) is add in support for a number of locale-aware things like this. There is both the presentation side of things and the validation side (after all, you need to be able to validate "1,23" when entered in the de locale, too). I've been looking at things like cmlenz's babel package and other things a bit lately, trying to work out what design we can use. We probably don't want to rely on bable unconditionally (for all Django uses), since we adhere to a "batteries included" policy as much as possible. But it might be possible to use something like that as an option -- use it if available. Before anybody gets all excited this isn't any kind of official decision. It's one possible alternative. There are others, too. What we can't do is use Python's locale module, since it's not thread-safe and we need different per-thread locale settings, obviously, as well as the ability to control the output via something like translation.activate() (in fact, probably exactly using that). So, this is on my radar, but not my current active project right at the moment. Have a look around at what's available. Try to come up with some ideas that will work for all locales. All contributions welcome, naturally. Regards, Malcolm -- Plan to be spontaneous - tomorrow. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---