您可以使用 ”safe http://docs.djangoproject.com/en/dev/topics/templates/#how-to-turn-it-off“在模板中或”标记安全 http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping” 看来,
关闭模板中的自动转义,
或者在表单中使用 Unicode 字符而不是 HTML 实体。
Using mark_safe
from django.utils.safestring import mark_safe
currencies = ((mark_safe('$'), mark_safe('$')),
(mark_safe('£'), mark_safe('£')),
(mark_safe('€'), mark_safe('€')))
Using autoescape off
作为模板中的替代方案,您可以关闭代码块的转义 http://docs.djangoproject.com/en/dev/topics/templates/#for-template-blocks。
标签之间的所有内容{% autoescape off %}
and {% endautoescape %}
不会被逃脱。
使用 Unicode 字符
当其他方法都不起作用时,请尝试以下操作。在包含货币元组的文件中,将以下行作为第一行或第二行:
# coding=utf-8
然后在您的货币元组中放入实际的 unicode 字符:
currencies = (('$', '$'),
('£', '£'),
('€', '€'))