← Django learning path
Django · Module 2 of 10

URLs and views

Map URLs to Python functions that return responses.

📖 Key ideas

  1. A view is a function taking request and returning HttpResponse.
  2. urls.py maps paths: path("about/", views.about).
  3. Include app URLs: path("blog/", include("blog.urls")).
  4. Path converters: path("post/<int:id>/", views.post).
  5. Class-based views (ListView, DetailView) reduce repetition.
💡 Real-life example: urls.py is a building directory board; views are the offices people are sent to.
ViewFunction or class handling a request
urls.pyURL patterns file
path()Maps a route to a view
include()Adds another URL file