June 08, 2025
What are templates in Django
Templates are very important in Django. These are HTML files which used to create user interfaces. We can pass variables and objects to Django template to load dynamic content. Through views we render templates. We can execute condition and loop statements also in Django templates. Examples of templates are mentioned below
html template
#student_details.html
<html>
<head>
<title>Student Details</title>
</head>
<body>
<h1>Hello, {{ student_name }}</h1>
</body>
</html>
html template render in view
from django.shortcuts import render
def student_details(request):
return render(request, 'student_details.html', {'name': 'Gaurav'})