Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django getting kwargs value in template

Lets say I have a function where I am passing template:

def somefunc(template, **kwargs):
    body = render_to_string(tempate, {"kwargs":kwargs})

In my template I want to access this kwargs value:

Hellooww {{kwargs['username'}}, welcome to the site...

But I am not getting this username. Can it be done this way?

Thank you

like image 765
varad Avatar asked Sep 01 '25 18:09

varad


1 Answers

You could use via view.kwargs for access to kwargs accessible in View:

enter image description here

like image 137
135 Avatar answered Sep 04 '25 06:09

135