[Django]-Django automatically append hyperlink url to the existing url

7👍

You should add / in your href attribute:

<a href="/home.html">home</a>

However, probbably the better solution is to use url tag. So it should look like:

<a href="{% url index %}">home</a>

Here you have a documentation about url dispatcher in Django.

And one more thing: you don’t need to have this *.html extension in your urls.

0👍

<a href="{% url 'index' %}">home</a>

It worked for me check the path in urls.py properly.

Leave a comment