Urls accumulating in DJANGO

Asked

Viewed 85 times

1

My urls are accumulating. When I pass via tag a[href="exemplo"] he sends it to url http://localhost:8000/index/, but if I click again on some other link from the same menu, it will redirect to http://localhost:8000/index/outrolocal and adding the other url after the example. How could I make him seek the url requested without bringing urls footsteps (/index/ in the case)?

I know I could put the "href="../outrolocal" of tag that will call, however, I am extending a menu, I do not want to put it all the time.

py.url

from geral.views import index, login, recuperar
urlpatterns = [
       path('', index),
       path('index/', index),
       path('login/', login),
]

general/view.py

from django.shortcuts import render

# Create your views here.
def index(request):
    return render(request, 'index.html')
def login(request):
    return render(request, 'login.html')
def recuperar(request):
    return render(request, 'recuperar.html')

html file.

<a href="index">Inicio</a>
<a href="login">Login</a>

1 answer

1


I don’t know Django but you can try:

<a href="/index">Inicio</a>
<a href="/login">Login</a>

instead of

<a href="index">Inicio</a>
<a href="login">Login</a>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.