251

これを一行でコメントしたい

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



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

4 に答える 4

386

Milesの回答として{% comment %}...{% endcomment %}、複数行のコメントに使用されますが、次のように同じ行のテキストをコメントアウトすることもできます:

{# some text #}
于 2009-04-06T00:13:16.680 に答える
151

コメント タグは、https://docs.djangoproject.com/en/stable/ref/templates/builtins/#std:templatetag-commentに記載されています。

{% comment %} this is a comment {% endcomment %}

1 行のコメントは、https://docs.djangoproject.com/en/stable/topics/templates/#commentsに記載されています。

{# this won't be rendered #}
于 2009-04-06T00:04:22.803 に答える
33

表記を使用する{# #}と、次のようになります。

{# Everything you see here is a comment. It won't show up in the HTML output. #}
于 2009-04-06T00:13:17.587 に答える