› Forums › Web Development › HarvardX: CS50W – CS50’s Web Programming with Python and JavaScript › CS50W – Lecture 3 – Django › Django Template Language (DTL): Beginner Learning Post
- This topic is empty.
-
AuthorPosts
-
April 19, 2026 at 9:52 am #6417
Django Template Language (DTL): What It Is and Why It Matters
When learning Django, one of the first terms you may encounter is:
DTLWhat exactly does it mean, and why is it important?
Short Answer
DTL stands for Django Template Language.
It is the system Django uses to combine:
HTML + Python Data + Simple Logic
So you can build dynamic web pages.
Simple Example
Python view:
def index(request): return render(request, "index.html", { "name": "Rajeev" })Template:
<h1>Hello {{ name }}</h1>Browser Output:
Hello Rajeev
How DTL Works
1. Python sends data
{ "name": "Rajeev" }2. Template receives data
{{ name }}3. Django replaces variable
Rajeev
Main Parts of DTL
1. Variables
Used to display values.
{{ title }} {{ user }} {{ name }}
2. Tags
Used for logic.
{% for item in items %} {% if user %} {% block body %} {% extends "layout.html" %}
3. Filters
Used to modify output.
{{ name|upper }}Result:
RAJEEV
Loop Example
{% for course in courses %} <li>{{ course }}</li> {% endfor %}If Python sends:
["Python", "Django", "AI"]Output:
Python Django AI
Template Inheritance
Base template:
<title>{% block title %}{% endblock %}</title> {% block body %}{% endblock %}Child template:
{% extends "layout.html" %} {% block title %} Encyclopedia {% endblock %} {% block body %} All Pages {% endblock %}This helps reuse layouts across many pages.
Important Note
DTL is not full Python.
You cannot write advanced Python code inside templates.
Templates should focus on presentation.
Why DTL Matters
DTL helps build:
Blogs Dashboards Wikis Portals Search Pages Dynamic Websites
Mental Model
Python = Data HTML = Structure DTL = Bridge Between Them
One-Line Takeaway
Django Template Language lets you display Python data inside HTML using clean and simple syntax.
-
AuthorPosts
- You must be logged in to reply to this topic.
