Articles → DJANGO → Verbatim Tag In Dynamic Template In Django

Verbatim Tag In Dynamic Template In Django






Purpose





Template


<html>
	<head></head>
	<body>
		<table border="1">
    {% for num in numbers %}
    {% if num|divisibleby:2 %}
    
			<tr>
				<td>            
            {%verbatim%}{{ num }}{%endverbatim%}
        </td>
				<td>
            Even
        </td>
			</tr>
    {% else %}
    
			<tr>
				<td>            
            {{ num }}
        </td>
				<td>
            Odd
        </td>
			</tr>
    {% endif %}
    {% endfor %}
 
		</table>
	</body>
</html>



Views.Py In Testmodule


from django.http import HttpResponse
from django.shortcuts import render

# Create your views here.
def home(request):
    return render(
        request, "FirstTemplate.html", {"numbers": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
    )



Output


Picture showing the output of verbatim tag in dynamic template in Django
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, June 17, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250