Introduction
Previous article lo manam Django project create chesam.
Ipudu chuddam 👉 user request vachinappudu Django ela respond avthundi?
Django lo Views & URLs anevi chala important concepts 🔥
🧠 Simple ga ardham:
👉 URL = address
👉 View = action (logic)
User URL enter chesthe → View execute avthundi
🔗 URLs ante enti?
Example:
http://127.0.0.1:8000/about/
http://127.0.0.1:8000/contact/
👉 /about/, /contact/ ni URLs antaru
Django lo ee URLs ni urls.py file lo define chestam
⚙️ urls.py Example
from django.urls import path
from . import views
urlpatterns = [
path('about/', views.about_view),
]
👉 Ikkada:
'about/'→ URLabout_view→ View function
⚡ Views ante enti?
👉 View ante Python function
User request vachinappudu:
👉 View function run avthundi
👉 Response return chestundi
💻 Simple View Example
from django.http import HttpResponse
def about_view(request):
return HttpResponse("Hello from About Page")
👉 Browser lo /about/ open chesthe:
👉 “Hello from About Page” kanipisthundi
🔄 Flow ardham chesko
User URL enter chestadu
Django →
urls.pycheck chestundiMatching URL dorikite → View call chestundi
View → Response return chestundi
🔥 Important Points
URLs → routing handle chestayi
Views → logic handle chestayi
Renditiki connection chala important
✅ Conclusion
Meeru ippudu Django lo URLs & Views ela panichestayo clear ga ardham chesukunnaru 🎉
🔜 Next Article
👉 Django Templates & HTML Rendering
Stay tuned 🔥
Comments
Post a Comment