Chamodh Nethsara
Chamodh Nethsara

Reputation: 41

How to add date-time arguments to django URL tag

I am trying to get this URL in my template.

    path('show_date/<int:year>/<int:month>/<int:date>/',show_date,name='show_date'),

My template

    <a href="{%url 'diary:show_date'{{date|date:'Y'}} {{date|date:'m'}} {{date|date:'j'}} 
%}">{{date}}</a>

returns this error

Could not parse some characters: 'diary:show_date'|{{date||date:'Y'}}

Please help me fix this issue

Upvotes: 0

Views: 183

Answers (1)

Iain Shelvington
Iain Shelvington

Reputation: 32244

You shouldn't add the double braces when you use a filter on a variable in a tag, you can use the filters without them

<a href="{% url 'show_date' date|date:'Y' date|date:'m' date|date:'j' %}">{{ date }}</a>

Upvotes: 2

Related Questions