Home »
Python »
Django MCQs
Which template tag is used to create variables directly in the Django template?
20. Which template tag is used to create variables directly in the Django template?
- {% with %}
- <% with %>
- << with >>
- {{ with }}
Answer: A) {% with %}
Explanation:
You can use {% with %} template tag inside the Django template to create variables directly. Consider the below example –
{% with name="Alvin" %}
<h1>Hey {{ name }}, Welcome!</h1>
{% endwith %}
The output of the following code will be –
Hey Alvin, Welcome!