Django: any use of blocktrans causes TemplateSyntaxError

前端 未结 2 475
醉酒成梦
醉酒成梦 2020-12-20 16:39

Using Django 1.2.1, any use of blocktrans breaks my template. Eg

{%blocktrans%}text{%endblocktrans%}

Results in:

Django Version: 1.

相关标签:
2条回答
  • 2020-12-20 17:12

    Just add that to your built-in tags like this, instead:

    # in urls.py
    template.add_to_builtins('django.templatetags.i18n')
    

    Any tag I'm using in multiple templates, I just load into there.

    0 讨论(0)
  • 2020-12-20 17:17

    Answering my own question, I'd forgotten:

    {% load i18n %}
    

    In the top of the template. This is required to use the blocktrans tag.

    Edit: See orokusaki's improved answer below to fix this permanently for all your templates.

    0 讨论(0)
提交回复
热议问题