我正在使用 Django 1.3。你能这么好心回答我一个问题吗?我正在从我的数据库中读取数据,其中编码设置为 untf8-unicode
settings.py
DEFAULT_CHARSET = 'utf-8'
file.py
# -*- coding: utf-8 -*-
def get_gift(gift_id):
gift = Gift.objects.get(id__exact = gift_id, is_visible = True)
return gift
def output():
gift = get_gift(gift_id)
title = gift.name.encode('utf-8')
return HttpResponse(title)
作为回应,我收到了 \u0411\u0435\u0441\u0435\u0434\u043a\u0430,但它应该是俄语(西里尔文)