[Answered ]-Django – Going back to a directory at a upper level from the template with href in django

1👍

When you define the urls. you can chose a name to use whenever into a django template, to reffer to this url

path('shirts/',views.shirts,name='shirts'),

now, inside a template

<a href="{% url 'shirts' %}">Shirts</a>

The name after the url within the ” is the NAME you define into your urls file

0👍

you can go to parent directory by .. so <a href='../../../shirts'> would be what you want,
or without changing the directory <a href='/shop/shirts'>.

but it’s better to use {% url 'url-name' %}

Leave a comment