Articles → DJANGO → Context In Templates In Django
Context In Templates In Django
Context In Templates
Example
- Create a template with template variable.
- Pass context in function-based view.
Create A Template With Template Variable
<html>
<head></head>
<body>
<h1>This is the first heading</h1>
<h2>This is the second heading</h2>
<h3>{{Name}}
</body>
</html>
Pass Context In Function-Based View
def home(request):
return render(request, "FirstTemplate.html", {
"Name": "Karan"
})
Output
Click to Enlarge