當試圖渲染Django模板文件中的谷歌應用程序引擎谷歌應用程序引擎模板的Unicode解碼問題
from google.appengine.ext.webapp import template
templatepath = os.path.join(os.path.dirname(file), 'template.html')
self.response.out.write (template.render(templatepath , template_values))
我遇到了以下錯誤:
<type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 17692: ordinal not in range(128)
args = ('ascii', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ -->
', 17692, 17693, 'ordinal not in range(128)')
encoding = 'ascii'
end = 17693
message = ''
object = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ -->
reason = 'ordinal not in range(128)'
start = 17692
看來,基本的Django模板引擎採用了「ascii」編碼,應該是「utf-8」。 任何人都知道可能會導致麻煩以及如何解決它? 謝謝。
DEFAULT_CHARSET的值是多少? 可能會有所幫助。 –
lavinio
2009-07-16 18:00:46