Django Template 设定某值
{% with name="World" greeting="Hello" %} <html> <div>{{ greeting }} {{name}}!</div> </html> {% endwith %}
注意如果template有其他控制语句,有可能出现嵌套错误,例如:
{% with name="D" %} {% for item in inputList %} <p> <button type="submit" value="{{name}}-{{forloop.counter0}}" name="bt">编辑</button> </p> {% endwith %} {% endfor %}
会报错,必须调整交换endwith和endfor的位置。
浙公网安备 33010602011771号