Python Forum

Full Version: Why use HTML in Django Template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am confuse in usage of HTML(.html) in Django templates,
why we can not use .py (python) in Django templates ?
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>