{% if x.title|length > 12 %} {{x.title|slice:":12"}}... {% else %} {{x.title}}...">

Django Templates

{% for x in featured %}
<li class="panel">
    <h3>
        {% if x.title|length > 12 %}
        {{x.title|slice:":12"}}...
        {% else %}
        {{x.title}}
        {% endif %}
    </h3>
    <h4>
        {% if x.details|length > 30 %}
        {{x.details|slice:":30"}}...
        {% else %}
        {{x.details}}
        {% endif %}
    </h4>

    <p class="btnlinks">
        <i>noch <span>{{x.free_lots}}</span> lose</i>
        <a href="{{base_url}}ProductDetails/?lotid={{x.lotteryid.0}}" class="btn">zuR verlosung</a>
        <a href="{{base_url}}ProductDetails/?lotid={{x.lotteryid.0}}" class="mainlinkto"><img src="{{ STATIC_PREFIX }}images/base/arrowyellow.png" /></a>
    </p>
    <p class="slids"><img src="data:image/gif;base64,{{x.picture}}" ></p>  
</li>
{% endfor %}

I want to translate zuR verlosung, noch, lose .i am in templates, if I use trans or block trans, it shows me an error, says

Invalid block tag: 'blocktrans', expected 'empty' oder 'endfor'

Thanks in advance

+3
source share
1 answer

From the docs :

To give the template access to these tags, put it {% load i18n %}at the top of your template.

+8
source

All Articles