I started studying Django a few days ago and i want that when I click on a button it takes me to the url of my api. This is my urls from my app:
from django.urls import path, include
from animes import views
from rest_framework import routers
router = routers.DefaultRouter()
router.register('animes', views.AnimesViewSet, basename='animes')
router.register('nota', views.NotasViewSet, basename='notas')
urlpatterns = [
...
path('api/', include(router.urls), name='api')
]
the problem from my template is here:
<a class="botao__link" href="{% url 'api' %}"><button class="botao__botao" type="submit">API</button></a>
when i write the url manually i can go to the api without problems , but I can't go clicking the button
CodePudding user response:
I'm not pretty sure but I think removing the type="submit" attribute should help
CodePudding user response:
After several attempts I solved the problem by passing an absolute url