Django templates

帅比萌擦擦* 提交于 2019-12-19 09:27:45

问题


{% 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 is showing me error says

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

Thanks in advance


回答1:


From the docs:

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



来源:https://stackoverflow.com/questions/5987793/django-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!