Reputation: 100
I created two html file (home.html, admin.html). Both are linked to each other. Django, first opens up the home.html
, with the url http://127.0.0.1:8000/home
and as soon as a particular link is clicked, it is supposed to open the admin.html
. Similarly, when a particular linked in admin.html
is clicked, it opens up home.html
.
But, the url keeps on extending eg.
127.0.0.1:8000/home -> 127.0.0.1:8000/home/admin -> 127.0.0.1:8000/home/admin/home
and so on.....
How to stop django from constantly appending the url.
127.0.0.1:8000/home
should open home.html
127.0.0.1:8000/home/admin
should open admin.html
Upvotes: 1
Views: 2697
Reputation: 36161
It looks like you have something like <a href="admin/">
in your template. This tells to the browser "go to the subdirectory admin please", while what you want is "go to the URL /admin from the root of my website".
What you need is to use the {% url %}
templatetag, which will prevent those sort of mistakes:
<a href="{% url 'my_admin_view' %}">Admin link</a>
Upvotes: 2