我想用一行评论:
{% if something.property %}
<table>
<tr>...
{% # this is a comment %}
{% if something.property %}
<table>
<tr>...
原文由 Alex. S. 发布,翻译遵循 CC BY-SA 4.0 许可协议
我想用一行评论:
{% if something.property %}
<table>
<tr>...
{% # this is a comment %}
{% if something.property %}
<table>
<tr>...
原文由 Alex. S. 发布,翻译遵循 CC BY-SA 4.0 许可协议
注释标签记录在 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 #}
原文由 Miles 发布,翻译遵循 CC BY-SA 3.0 许可协议
4 回答4.4k 阅读✓ 已解决
4 回答3.8k 阅读✓ 已解决
1 回答3k 阅读✓ 已解决
3 回答2.1k 阅读✓ 已解决
1 回答4.5k 阅读✓ 已解决
1 回答3.8k 阅读✓ 已解决
1 回答2.8k 阅读✓ 已解决
作为 Miles 的回答,
{% comment %}...{% endcomment %}
用于多行注释,但您也可以像这样在同一行注释掉文本: