无法向模板添加其他阻止标签

时间:2019-03-01 09:14:48

标签: django python-3.x django-templates

我正在尝试在for循环内添加不同的块标签,但会引发错误

  

您忘记注册或加载此标签了吗?

但是我注册了

{% for todo in todo_list %}
{% if todo.complete %}{% else %}

        {{todo.text|capfirst|truncatechars:150}} </a> <br>
        <small class="text-muted">{{todo.content|capfirst}}{% empty %} {% endif %} </small> <hr>

{% endif %}   {% endfor %}

谢谢

1 个答案:

答案 0 :(得分:2)

调查您的问题,我认为您需要尝试以下操作:

{% for todo in todo_list %}
    {% if todo.complete %}
    {% else %}
        {{todo.text|capfirst|truncatechars:150}} </a> <br>
        {% if todo.content %}
            <small class="text-muted">{{todo.content|capfirst}} </small> <hr>
        {% else %}
            //do something 
        {% endif %}  
    {% endif %} 
{% endfor %}