当试图渲染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