How to set a value of a variable inside a template code? October 3, 2022 by Tarik You can use the with template tag. {% with name="World" %} <html> <div>Hello {{name}}!</div> </html> {% endwith %}