UNIT 05 · TOPIC 04
Django URLs
URL patterns map browser paths to view functions or class-based views.
The idea
Django URLs, simply explained
URL patterns map browser paths to view functions or class-based views.
01
See the big picture
How the idea flows
Read the diagram as a simple path: begin with a problem, use the Python idea, then verify the result.
02
Everyday connection
Real-life example
↗
A site maps /courses/ to the course list and /courses/7/ to one course's details.
03
Learn by doing
Python code example
PYTHONExample
from django.urls import path
from . import views
urlpatterns = [path('hello/', views.hello_view, name='hello')]Expected result
GET /hello/ calls hello_viewTry it: Change one value in the code, predict what will happen, then run it and compare your answer.
04
Keep this in mind
Key takeaways
- URL patterns map browser paths to view functions or class-based views.
- Think of a real problem where django urls could save time or organize information.
- Test small changes and read the result carefully before moving to a bigger program.
Quick self-check
Can you explain it in your own words?
What is the main idea of Django URLs?
URL patterns map browser paths to view functions or class-based views.
Where could you see this idea in everyday life?
A site maps /courses/ to the course list and /courses/7/ to one course's details.
