/challeges/1 處的 TemplateSyntaxError
無法決議余數:來自 '1:' 的 ':'
這是我的挑戰.html
{% if month == 1: %}
<h1>This is {{ text }}</h1>
{% else: %}
<p>This is {{ text }}</p>
{% endif %}
這是我的意見.py
def monthly_challege(request, month):
return render(request, "challeges/challege.html", {
"text": "Your Url Is Empty",
month: month
})
這是我的urls.py
urlpatterns = [
path("<month>", views.monthly_challege),
]
uj5u.com熱心網友回復:
您的 if ... else ... 陳述句中有錯字。它應該是
{% if month == 1 %}
<h1>This is {{ text }}</h1>
{% else %}
<p>This is {{ text }}</p>
{% endif %}
根據檔案如果其他檔案
uj5u.com熱心網友回復:
我找到了,這里是錯誤
你必須洗掉分號
before
{% if month == 1: %}
<h1>This is {{ text }}</h1>
{% else: %}
<p>This is {{ text }}</p>
{% endif %}
after
{% if month == 1 %}
<h1>This is {{ text }}</h1>
{% else %}
<p>This is {{ text }}</p>
{% endif %}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/529154.html
