开发者

How to escape modulo in Django translation strings (ugettext_lazy)

开发者 https://www.devze.com 2023-02-25 02:49 出处:网络
class MyModel(models.Model): test = models.CharField(_(\"100% of escaping problems sucks\"), max_length=50)开发者_运维问答
class MyModel(models.Model):
    test = models.CharField(_("100% of escaping problems sucks"), max_length=50)开发者_运维问答

The string is then threated as a python-format in gettext because it contains a modulo (%)

How do I escape it ?


This is the only workaround I found to be working... and it's ugly as hell:

class MyModel(models.Model):
    test = models.CharField(_("100%(bs)s of escaping problems sucks") % {'bs': '%'}, max_length=50)
0

精彩评论

暂无评论...
验证码 换一张
取 消