Ojas Kale
Ojas Kale

Reputation: 2159

How to assign current year in with tag

In django I want to do something like this, which will pass current year to url name

{% with now "Y" as year %}
<a href="{% url 'createAwardWinner' year  %}"><i class="fa fa-gavel fa-fw"></i> Create</a>
{% endwith %}

but its not able to interpret I want to do

year = now 'Y'

How should I do this

Upvotes: 1

Views: 238

Answers (1)

Emilio Conte
Emilio Conte

Reputation: 1145

Did you simply try:

{% now "Y" as current_year %}
<a href="{% url 'createAwardWinner' current_year  %}"><i class="fa fa-gavel fa-fw"></i> Create</a>

Upvotes: 4

Related Questions