using UTF8 replace the others On 6/3/07, Roger <[EMAIL PROTECTED]> wrote: > > Hi all, > I am pretty new to django, and am trying fix some code I inherited, so > far I have much success and have > been impressed with Django. > > I do have one problem I hope someone here can help me with. I have > some messages in the database in several languages. When I read the > English text, no problem. When I read the german text, it comes out > with the umlauts (üöä) garbled. > > The model looks like this: > > class StandardMessage(meta.Model): > message_id = meta.PositiveIntegerField() > text = meta.CharField(maxlength=80) > type = meta.CharField(maxlength="1", choices=(PS_Choices), > default='Y') > lang = meta.CharField(maxlength="5", blank=False) > > def get_translate_message(self, _lang): > from django.models.dating import standartmessages > try: sm = > standartmessages.get_object(message_id__exact=self.message_id, > lang__exact=_lang) > except Exception, e: print e;sm=None > if not sm: > sm1 = StandartMessage(type = self.type, lang=_lang, > message_id=self.message_id) > sm1.save() > return sm1 > return sm > > And it's used like this: > ..... > defmesList = standartmessages.get_list(type__exact=mtype, > lang__exact=_lang) > result += '</option>' + '\n' > for elem in defmesList: > result += '<option value=\"' > result += str(elem.message_id) +'\">' > result += elem.get_translate_message(_lang).text > #result += "äöü" # This is a test, and these > charachters are displayd correctly ! > result += '</option>' + '\n' > pass > result +='</select>' + '\n' > > If I add umlauts in the handling routine (the second piece of code), > they are displayed on the output page correctly, so it looks like the > problem is occurring earlier.... > > I have tried putting # -*- coding: iso-8859-1 -*- at the start of the > modules concerned but no success. > > I would be most grateful for any help with this.. > > Roger > > > > >
-- [EMAIL PROTECTED] 13585201588 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---