Justin Bayer wrote: > Hi django-users, > > I developed an application locally and used it with my postgres > database, which used unicode as the server_encoding. Everything worked > fine. > > Recently I deployed it onto a system where the postgres server_encoding > is sql_ascii. > > After install, I started admin and added an object to the database > which contained an `รค`. Django did not warn me and wrote the object > into the database. But Django is unable to retrieve the object now and > crashes with a UnicodeDecodeError. Furthermore I can not access the > admin because of admin's `last change` list. > > Clearing the tables brought me back to the start. > > Is there an elegant way to solve this not making me overwrite every > save method and changing the databases encoding? >
hi, this way works perfectly: - have EVERYTHING in utf8 :) now i'm not sure which way would you like to arrive at a working solution. one thing is clear: - if you want to store non-ascii content in an ascii database, then that would be problematic (read "impossible" :). so your best guess would be to migrate the db to utf8 (i think dumping the db, then creating an utf8 one, and importing the data should work) then fix your templates, and there shouldn't be anything to do for the views. and also make sure, that everytime when you are really "processing" the data (shortening it to a given length, iterating over it character-by-character, etc..) then first you have to convert your text to unicode-strings, do the processing, and then convert back to byte-strings there are some plans to convert django to unicode, but it's not clear yet when that will happen. with all this said, if you keep everything in UTF8, you should be fine (in fact, theoretically you could use any other unicode-complete charset (like utf-16 or utf-32), but utf8 is basically the ideal one in nearly all the cases). gabor --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@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-developers -~----------~----~----~----~------~----~------~--~---