Naveen T’s Post

Day 92 – Mastering Django Template Variables & Tags Today I explored how Django dynamically passes and displays data in HTML using Template Variables, Tags, and Loops 🔥 🔹 Django Template Variables Used to display dynamic data in HTML 👉 Syntax: {{ variable_name }} ✔️ Data is passed from views.py as a dictionary ✔️ Keys are accessed directly in HTML 🔹 Django Template Tags Used for logic like conditions and loops 👉 Syntax: {% condition %} ✔️ Supports if-else, for loop, and more ✔️ Must properly close tags like {% endif %} and {% endfor %} 🔹 What I Did Today ✔️ Passed data from views.py using dictionary ✔️ Displayed values in HTML using {{ }} ✔️ Applied conditions using {% if %} ✔️ Implemented loops using {% for %} to iterate lists ✔️ Learned direct data passing inside render() 🔹 Example Learnings 📌 Display Data: {{ Name }} 📌 Condition: {% if Age > 18 %} → Eligible / Not Eligible 📌 Loop: {% for i in Name %} → Prints each value one by one 🔹 How It Works 👤 User → URL ➡️ urls.py maps request ➡️ views.py sends data via dictionary ➡️ Template receives data ➡️ Variables & Tags process it ➡️ Final output displayed 🎉 🔹 Key Takeaway Django Templates make websites dynamic, allowing us to control both data and logic inside HTML itself. This is where backend truly connects with frontend in a powerful way 💡 #Django #Python #WebDevelopment #BackendDevelopment #Frontend #FullStackDevelopment

To view or add a comment, sign in

Explore content categories