我想用一句话来评论这一点:

{% if something.property %}
    <table>
        <tr>...



{% # this is a comment %}
{% if something.property %}
    <table>
        <tr>...

当前回答

注释标签在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 #}

其他回答

使用{# #}符号,如下所示:

{# Everything you see here is a comment. It won't show up in the HTML output. #}

如果你想在{% extends…%} 在这种情况下最好使用

<!--
# comment 1
# comment 2
# comment 3
-->

作为Miles的回答,{% 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 #}

这是单行注释:

{# <p>This is comment</p> #}

这是多行注释:

{% comment "This is an optional note for comments" %}
    <p>This is comment</p>
    <p>This is comment</p>
    <p>This is comment</p>
{% endcomment %}