Today while trying to my final product to one of our customer's an ugly little error shot back at me when I tried editting any of the imported records into the database. "django ascii codec can't encode ..." bla bla it would complain and refuses to render the said template. Tracking down the problem down, I found it to the __str__ method being returned one of my models.
After changing the database encoding for my MySQL database ( sucky on windoze ), it still stubbornly spat back the same error at me. Finally after searching around more I found the smart_str method's usage here.
Kudos! It works now. So instead of returning the normal 'str(self.name)' I do a 'smart_str(self.name)' and everything is back to it's hunky doriness!
Thursday, March 19, 2009
Subscribe to:
Post Comments (Atom)
2 comments:
It was rendering the __str__ of a model? are you already declaring the __unicode__ method for your models?
Yeah tried the __unicode__ method with and without the __str__ method as suggested by the manual. Did not work out.
Post a Comment