我想用一行评论
{% if something.property %} <table> <tr>... {% # this is a comment %} {% if something.property %} <table> <tr>...
作为Miles的答案,{% comment %}...{% endcomment %}它用于多行注释,但是你也可以像这样在同一行上注释掉文本:
{% comment %}...{% endcomment %}
{# some text #}
注释标签记录在https://docs.djangoproject.com/en/stable/ref/templates/builtins/#std:templatetag-comment
{% comment %} this is a comment {% endcomment %}
单行注释记录在https://docs.djangoproject.com/en/stable/topics/templates/#comments
{# this won't be rendered #}