I need to get the param of the url inside a html file, but I need to know if is possible in a tag, or how can I get the url params using Class-based views?
My urls.py file
from django.urls import path
from .views import UsersView
urlpatterns = [
path('list/<int:pk>/', UsersView.as_view(), name='user_list'),
]
My html file:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Users</title>
</head>
<body>
{{ request.GET.pk }}
</body>
</html>
CodePudding user response:
You can use
self.kwargs['pk']
Inside a CBV to get the URL parameter, since there is a <int:pk>