pythondjangodjango-templatespinax

Why is Django blocktrans working one place and not another?


I have two Django templates (in a Pinax 0.9.x project) with text in a blocktrans block. One is working and the other isn't.

The one that's working looks like:

{% extends "site_base.html" %}

...

{% block body %}

    <h1>ABC</h1>

    <h2><em>DEF</em></h2>

    <p>
        {% blocktrans %}
        GHI
        ...

The one that's not working is getting a debug mode error of:

TemplateSyntaxError at /JKL/
Invalid block tag: 'blocktrans', expected 'endblock' or 'endblock body'

It follows those headings by giving the following source code, with the blocktrans highlighted in red:

{% extends "site_base.html" %}
{% block head_title %}MNO{% endblock %}

{% block body %}
    <p>
        {% blocktrans %}
        PQR
        {% endblocktrans %}
    </p>

Are these two blocks of code isomorphic? If they aren't, what is the difference? What should I be doing to have paragraphs with their content working in blocktrans tags?

Thanks,


Solution

  • You have to load the i18n template tags:

    <!-- your_template.html -->
    {% load i18n %}