无效的块标记:' shift_info',预期'空' ili' endfor' Django的

时间:2014-10-12 22:20:29

标签: python django

所以,我在这里访问了很多关于Django块标签的问题,但是在我的特定问题中我无法从中学习。

week_table.html

    {% load base_extras %}
...
    {% for shift in shifts %}
        {% if shift.user %}
            {% if user in shift.user.all or shift.user.count < shift.usernum %}
                <td class="clickable" href="{% url 'termini:shift_add_remove' shift.id %}">{% if shift.name %}{{ shift.name }}<br>{% endif %}{% for usr in shift.user.all %}{% shift_info usr %}{% endfor %}</td>
                {% else %}
                    <td>{% if shift.name %}{{ shift.name }}<br>{% endif %}{% for usr in shift.user.all %}{% shift_info usr %}{% endfor %}</td>
                    {% endif %}
                {% else %}
                    <td class="clickable" href="{% url 'termini:shift_add_remove' shift.id %}">{{ shift.name|default:"" }}</td>
            {% endif %}
    {% endfor %}

问题是我得到无效的块标记:'shift_info',预期'空'ili'结束'错误

shift_info在base_extras.py

中定义

base_extras.py

from django import template
import re

register = template.Library()
@register.simple_tag
def user_info(user):
    name = '%s %s' % (user.first_name, user.last_name)
    if not name.strip():
        name = user.username
    return name

1 个答案:

答案 0 :(得分:0)

这是一个简单的拼写错误案例,而不是查看自己的代码......