Template variables with double braces
📖 Scenario: You are building a simple Django web page to show a user's profile information. The data will come from the backend and be displayed in the HTML template.
🎯 Goal: Create a Django template that uses double braces {{ }} to show the user's name and age on the page.
📋 What You'll Learn
Create a dictionary called
user with keys 'name' and 'age' and exact values 'Alice' and 30Create a variable called
title with the value 'User Profile'Use double braces
{{ }} in the template to display title in an <h1> tagUse double braces
{{ }} in the template to display user.name and user.age inside <p> tags💡 Why This Matters
🌍 Real World
Django templates use double braces {{ }} to safely insert data from the backend into HTML pages, making dynamic websites.
💼 Career
Understanding Django template variables is essential for backend web developers working with Python and Django to build interactive web pages.
Progress0 / 4 steps