Kar*_*lgo 1 django unicode internationalization
我的网站需要能够以不同语言提供数据.我设置它所以它使用utf-8并且db设置也被设置为.我一直在管理员身上得到不同的unicode错误.
例如:
如果我为模型设置unicode方法返回例如:
return u'%s' % unicode(self.tag)
Run Code Online (Sandbox Code Playgroud)
这似乎解决了#1和#2,但那时我得到了#3.
我一直在寻找一个解决方案,但找不到能解决所有不同错误的东西.处理这些问题的最佳方法是什么?
from django.utils.encoding import smart_unicode
...
def __unicode__(self):
return smart_unicode(self.tag)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7310 次 |
| 最近记录: |