How to set a value of a variable inside a template code?

django, django-templates

Solution

You can use the `with` template tag.

{% with name="World" %}     
<html>
<div>Hello {{name}}!</div>
</html>
{% endwith %}

Problem

Say I have a template ``` <html> <div>Hello {{name}}!</div> </html> ``` While testing it, it would be useful to define the value of the variable without touching the python code that invokes this template. So I'm looking for something like this ``` {% set name="World" %} <html> <div>Hello {{name}}!</div> </html> ``` Does something like this exists in Django?

Original source

Related problems