否则不在Django工作,我不知道该如何解决

时间:2019-11-24 20:52:59

标签: django

Request Method: GET
Request URL:    http://127.0.0.1:8000/articles/
Django Version: 2.2.7
Exception Type: TemplateSyntaxError
Exception Value:    
Invalid block tag on line 12: 'else', expected 'endblock'. Did you forget to register or load this tag?

{% extends 'base.html' %}

{% block title %}Ultemele statii{% endblock %}

{% block content %}

    {% if latest_articles_list % }

        {% for a in latest_articles_list %}
            <a href="#">{{a.article_title}}</a>
        {% endfor %}
    {% else %}
        statii ne naidena ))=
    {% endif %}

{% endblock %}

代码不起作用

1 个答案:

答案 0 :(得分:0)

您的代码看起来不错,除了 if 语句中的 extra 空格:

{% extends 'base.html' %}

{% block title %}Ultemele statii{% endblock %}

{% block content %}

    {% if latest_articles_list %}

        {% for a in latest_articles_list %}
            <a href="#">{{a.article_title}}</a>
        {% endfor %}
    {% else %}
        statii ne naidena ))=
    {% endif %}

{% endblock %}