当我在模型的 help_text 上使用 pgettext_lazy 时,我的模板失败了。它适用于 ugettext_lazy。
错误
Caught TypeError while rendering: Lazy object returned unexpected type.
模型
class BalanceIncreaseOrder(models.Model):
amount = models.FloatField(help_text=pgettext_lazy("Translators: please localize this to reflect the correct currency", "Note: amount will be billed in United States dollars (USD)"))
形式
class BalanceIncreaseOrderForm(ModelFormRequired):
class Meta:
model = BalanceIncreaseOrder
fields = ("amount",)
模板
{% for field in form %}
{{ field }}
{% endfor %}
在每种方式设置帮助文本之后,我已经调试了模型。两次都打印出来
<django.utils.functional.__proxy__ object at 0x10fcb3a50>
pgettext_lazy 中是否有错误?有任何想法吗?