Django 註釋標籤
註釋
註釋允許您擁有應該被忽略的程式碼段。
示例
<h1>Welcome Everyone</h1>
{% comment %}
<h1>Welcome ladies and gentlemen</h1>
{% endcomment %}
執行示例 »
註釋說明
您可以在註釋中新增一條訊息,以幫助您記住編寫註釋的原因,或作為給其他閱讀程式碼的人的訊息。
示例
為您的註釋新增說明
<h1>Welcome Everyone</h1>
{% comment "this was the original welcome message" %}
<h1>Welcome ladies and gentlemen</h1>
{% endcomment %}
執行示例 »
更小的註釋
您還可以使用 {# ... #}
標籤來註釋掉程式碼,這對於較小的註釋更容易
在 Views 中添加註釋
Views 用 Python 編寫,Python 註釋用 #
字元編寫
示例
註釋掉 View 中的一段
from django.http import HttpResponse
from django.template import loader
def testing(request):
template = loader.get_template('template.html')
#context = {
# 'var1': 'John',
#}
return HttpResponse(template.render())
執行示例 »
閱讀我們 Python 註釋教程 中關於 Python 註釋的更多內容。