Erfan
Erfan

Reputation: 379

django template access url kwargs

I want to access kwargs with their names in url from "django template tags". for example i have a url as below:

path('sample_view/<slug:my_custom_slug>/', views.sample_view.as_view(), name='sample_view')

what should I write in my html template to access "my_custom_slug"?

Upvotes: 0

Views: 117

Answers (1)

Negar37
Negar37

Reputation: 362

You can try this:

{{request.resolver_match.kwargs.my_custom_slug}}

Upvotes: 1

Related Questions