Dec-09-2019, 01:25 AM
I am confuse in usage of HTML(.html) in Django templates,
why we can not use .py (python) in Django templates ?
why we can not use .py (python) in Django templates ?
Why use HTML in Django Template
|
Dec-09-2019, 01:25 AM
I am confuse in usage of HTML(.html) in Django templates,
why we can not use .py (python) in Django templates ?
Dec-09-2019, 02:07 AM
Every web site is ultimately HTML, the following link explains it well: https://docs.djangoproject.com/en/2.2/topics/templates/
If would be cool in browser could read
.py ,but that's not the case browsers read html.Template allow us to transfer Python-like code into html. So eg on server. my_list = [1,2,3]Template. <ul> {% for post in my_list %} <li>{{ post }}</li> {% endfor %} </ul>What the browser read and render from this template is real html,as that's what the browser understand. <ul> <li>1</li> <li>2</li> <li>3</li> </ul> |
|