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 %}
代码不起作用
你的代码看起来不错,除了if语句中的额外空格:
{% 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 %}