【发布时间】:2013-03-30 18:27:09
【问题描述】:
我将GeoDjango 示例与class WorldBorder 一起使用。
我的麻烦是我无法打印出所选国家的名称。当我尝试执行时
from django.utils.translation import ugettext_lazy as _
...
location = fromstr(... , srid=4326)
country = WorldBorder.objects.get(mpoly__intersects=location)
print _('User country determined to %s') %country.name
我收到错误消息:
Python: TypeError: 'unicode' object is not callable
当我删除 ugettext_lazy 时,一切正常。 我怎样才能保留翻译选项并使字符串正常工作?
【问题讨论】:
-
您的错误的完整回溯是什么?在异常点上,
print repr(_)给了你什么? -
Django 从未抛出完整的回溯,因为所有内容都被
except捕获。删除测试异常显示,未导入 GeoDjango 类。可悲的错误。谢谢你的提示。 -
对,教训是:不要使用空白的
except子句! :-)
标签: python django unicode typeerror