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?

  1. {% with %}
  2. <% with %>
  3. << with >>
  4. {{ 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!

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.