1
我有一個表格,我試圖在HTML中的if-else
循環之間插入靜態圖像文件。這裏是模板的源代碼:Django:無效塊標記:'靜態',預計'endif'
<!DOCTYPE html>
<html>
<head>
<title>Rango</title>
</head>
<body>
<p>
<ul>
{% if user and not user.is_anonymous %}
<li>
<a>Hello {{ user.get_full_name|default:user.username }}!</a>
</li>
<li>
<a href="{% url 'auth:logout' %}?next={{ request.path }}">Logout</a>
</li>
{% else %}
<li>
<a href="{% url 'social:begin' 'twitter' %}?next={{ request.path }}"><img src="{% static "images/twitter.png" %}" /></a>
</li>
{% endif %}
</ul>
</p>
<form id="evangelized_form" method="post" action="/rango/fillform/">
{% csrf_token %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% for field in form.visible_fields %}
{{ field.errors }}
<b>{{ field.help_text }}</b><br>
{{ field }}<br><br>
{% endfor %}
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
但是,這是我遇到的錯誤:
TemplateSyntaxError at /rango/fillform/
Invalid block tag: 'static', expected 'endif'
如何靜態圖像在Django模板if-else
環路之間插入?