django国家/地区无法获取国家/地区名称

django国家/地区无法获取国家/地区名称,django,Django,根据文件 >>> person.country Country(code='NZ') >>> person.country.name u'New Zealand' 应该是检索国家名称的unicode的一种方法。然而,当我尝试它时,我得到了 >>> obj.country Country(code='AX') >>> obj.country.name <django.utils.functional.__proxy__

根据文件

>>> person.country
Country(code='NZ')
>>> person.country.name
u'New Zealand'
应该是检索国家名称的unicode的一种方法。然而,当我尝试它时,我得到了

>>> obj.country
Country(code='AX')
>>> obj.country.name
<django.utils.functional.__proxy__ object at 0x91b81ac>
即使使用
print object.country.name
也会打印相同的对象。为什么它不起作用

编辑:抱歉,我刚刚将name对象作为示例:p

callunicode()

从django.utils.translation导入ugettext\u
u=ugettext\u lazy(‘你好’)
打印u
#输出:
打印unicode(u)
#出去:你好

如果在模板中呈现,通常不会出现问题。

我不认为对象是保留字,但您能否尝试给它另一个名称以确保其正确性?
('AX', ugettext_lazy('\xc5land Islands'))
from django.utils.translation import ugettext_lazy

u = ugettext_lazy('hello')
print u
# out: <django.utils.functional.__proxy__ object at 0x158edd0>

print unicode(u)
# out: u'hello'