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