【发布时间】:2010-11-11 11:14:38
【问题描述】:
尝试在 Google App Engine 中呈现 Django 模板文件时
从 google.appengine.ext.webapp 导入模板
templatepath = os.path.join(os.path.dirname(file), 'template.html')
self.response.out.write (template.render( templatepath , template_values))
我遇到以下错误:
: “ascii”编解码器无法解码字节 0xe2 在位置 17692:序数不在 范围(128)
args = ('ascii', '个美丽的方法来找到内心的平静/ -->
', 17692, 17693, '序数不在范围内(128)')
编码 = 'ascii'
结束 = 17693
消息 = ''
object = '个美丽的方法来找到内心的平静/ -->
原因 = '序数不在范围内(128)'
开始 = 17692
似乎底层的django模板引擎已经假定了“ascii”编码,应该是“utf-8”。 谁知道可能是什么导致了麻烦以及如何解决? 谢谢。
【问题讨论】:
-
你的 DEFAULT_CHARSET 值是多少? docs.djangoproject.com/en/dev/ref/request-response> 可能会有所帮助。
标签: python django google-app-engine unicode