Home > Blockchain >  How to add date-time arguments to django URL tag
How to add date-time arguments to django URL tag

Time:10-27

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

CodePudding user response:

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>
  • Related