On Mon, 2008-11-24 at 11:06 -0800, Ulf Kronman wrote: > Hi all, > I need your help on this. > > Suddenly this weekend my templates on my Win XP box started breaking > with the error message: > TemplateSyntaxError at /vr/isi/items/ > Caught an exception while rendering: invalid literal for int() with > base 10: '' > > The template line causing the problem is: > <th> {{ flt_cy_average|floatformat }} </th> > > If I check the value of flt_cy_average it is: > 'flt_cy_average': 1.2436554207945787 > > If I hardcode the variable to a string with a comma delimiter it > passes without error: > flt_cy_average = '1,24' > > I'm running the code on Windows XP, Swedish version and the same code > is working on an Ubuntu server without any problems. Is the problem > that the template engine is picking up my Swedish locale and how do I > change this.
I don't have any solution to your problem. I don't use Windows, so I have no idea what the fix might be (well, I do, but "for the love of all that is decent, stop using Windows!" sounds like an option you would have already considered). But if you do find a solution, it would be interesting to know what it is. Working smoothyl on all our supported platforms is the goal, so if there's some way we can work around this, we should do it. Django doesn't call setlocale() itself and it would be a little tricky to do so (it affects the locale for all threads in that process, which could well lead to interesting behaviour on a multipthreaded Apache setup, for example). It sounds like your diagnosis is correct. That is, float() is trying to operate in a Swedish locale. I know that libraries like GLib have their own "parse a float" function that emulates the C library's float() but without taking locale into effect. Maybe we will end up having to do the same. Complete pain in the neck and it would be nice if there was a more OS-local solution, but it's an option if all else fails. Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---