Variables - Django Templates Last Updated : 30 Oct, 2025 Comments Improve Suggest changes 8 Likes Like Report Django templates allow HTML to be dynamically generated by combining static content with data passed from views. Variables are used to display this dynamic data within templates. Important things about variables are:Variables come from the context dictionary provided by the view.They render values directly into HTML.Can display dynamic content such as strings, numbers, lists, or objects.Enable separation of presentation from business logic.Syntax{{ variable_name }}Example: Passing a context with the following data{ 'first_name': 'Rahul', 'last_name': 'Kumar'}And in template:My first name is {{ first_name }}. My last name is {{ last_name }}.Output:My first name is Rahul. My last name is Kumar.Django Template Language (DTL) allows dynamic data from views to be rendered directly within HTML templates.Implementation ExampleConsider a project called 'geeksforgeeks' with an app named 'geeks':1. Create a View with Context DataIn geeks/views.py: Python from django.shortcuts import render def geeks_view(request): context = { "first_name": "Prajjwal", "last_name": "Vishwakarma", } return render(request, "geeks.html", context) 2. Configure URL RoutingIn geeks/urls.py: Python from django.urls import path from . import views urlpatterns = [ path('',views.geeks_view, name = 'geeks_view'), ] 3. Create the TemplateCreate a file named geeks.html inside the app’s templates folder. If the folder doesn’t exist, create it first. All HTML files for the app should be placed in this folder. html My First Name is {{ first_name }}. <br/> My Last Name is {{ last_name }}. Run the development server using python manage.py runserver and Visit: http://127.0.0.1:8000/:Snapshot of the development server Create Quiz Comment N NaveenArora Follow 8 Improve N NaveenArora Follow 8 Improve Article Tags : Python Python Django Django-templates Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 4 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library - Tutorial 3 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 5 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like