Skip to main content

Django Templates & HTML Rendering (Complete Guide Telugu)

 


Introduction

Previous article lo manam Views & URLs chusam.
Ipudu next important concept 👉 Templates & HTML Rendering

Django lo dynamic HTML pages ela create cheyyalo ee article lo nerchukundam 🔥


🧠 Templates ante enti?

👉 Template ante HTML file

But special enti ante:
👉 Dynamic data display cheyyachu (Python data → HTML lo show)


📁 Templates folder create cheyyadam

Mee app lo templates ane folder create cheyandi:

myapp/
    templates/
        index.html

⚙️ settings.py lo config cheyyali

settings.py open cheyandi:

TEMPLATES = [
    {
        'DIRS': [],
        ...
    },
]

👉 Usually app templates automatic ga detect chestundi


💻 Simple HTML Template

index.html:

<!DOCTYPE html>
<html>
<head>
    <title>Django Page</title>
</head>
<body>
    <h1>Hello {{ name }}</h1>
</body>
</html>

👉 {{ name }} → dynamic data placeholder


⚡ View lo render cheyyadam

from django.shortcuts import render

def home(request):
    return render(request, 'index.html', {'name': 'Manju'})

👉 Output:
👉 “Hello Manju” page lo kanipisthundi 🎉


🔗 URL connect cheyyadam

from django.urls import path
from .views import home

urlpatterns = [
    path('', home),
]

🔄 Flow ardham chesko

  1. User URL open chestadu

  2. URL → View ki velthundi

  3. View → Template render chestundi

  4. Data → HTML lo display avthundi


🔥 Template Tags

Django lo special syntax untundi:

  • {{ variable }} → data display

  • {% %} → logic (loops, conditions)

Example:

{% if name %}
    <h1>Hello {{ name }}</h1>
{% endif %}

✅ Conclusion

Meeru ippudu Django lo HTML pages dynamic ga render cheyyadam nerchukunnaru 🎉


🔜 Next Article

👉 Django Static Files (CSS, JS, Images)

Stay tuned 🔥

Comments

Popular posts from this blog

Django ante enti? (Beginner Friendly Telugu Guide)

  Introduction Meeru web development start cheyyali anukuntunnara? Leka backend development nerchukovali anukuntunnara? Appudu meeru tappakunda vinnadi oka peru 👉 Django Ee article lo manam simple ga, clear ga ardham ayyela chuddam — Django ante enti, enduku use chestaru, ela start cheyyali.

Django Project Create Ela Cheyyali? (Step-by-Step Telugu Guide) image ivvu mari

Introduction Previous article lo manam Django ante enti ani chusam. Ipudu manam practical ga Django project create ela cheyyalo nerchukundam. Ee guide beginner ki kuda easy ga ardham ayyela untundi 👍 🧰 Requirements Start cheyyadaniki mundu: Python install ayyi undali Internet connection undali 🚀 Step 1: Django Install Cheyyadam Command prompt open cheyandi: pip install django Install ayindho ledo check cheyyadaniki: django-admin --version 📁 Step 2: New Project Create Cheyyadam Command run cheyandi: django-admin startproject myproject 👉 Idi myproject ane folder create chestundi 📂 Project Structure Create ayina folder lo files ila untayi: manage.py myproject/ init .py settings.py urls.py asgi.py wsgi.py 👉 settings.py → project settings 👉 urls.py → URL routing ▶️ Step 3: Project Run Cheyyadam First project folder lo ki vellandi: cd myproject Server run cheyyandi: python manage.py runserver 🌐 Step 4: Browser lo Open Cheyyandi Browser open chesi: 👉 http://127.0.0.1:8000/ Open c...