在django中我想做类似这样的事情,这会将当前年份传递给网址名称
{% with now "Y" as year %}
<a href="{% url 'createAwardWinner' year %}"><i class="fa fa-gavel fa-fw"></i> Create</a>
{% endwith %}
但它无法解释我想做什么
year = now'Y'
我该怎么做
答案 0 :(得分:5)
您是否只是尝试:
{% now "Y" as current_year %}
<a href="{% url 'createAwardWinner' current_year %}"><i class="fa fa-gavel fa-fw"></i> Create</a>