← Django Foundations
6 / 25
Lesson 6 — URL routing
URLs point to views
Django's URLconf (the urls.py file) is a list that says which view handles which address: path("about/", views.about). When a request comes in, Django finds the matching path and calls its view; if nothing matches, it returns a 404 ("not found").
We model it with a dict from path to function:
routes = {"/": home}
routes.get("/x", not_found) # missing key -> not_found
Note: the exercise runs in your browser without Django installed, so it is a small plain-Python simulation of what Django does for you.
Why it matters: routing decides what every link on your site opens.
Want it another way?
Task
Add an "/about" route that returns "About", so all three lines print correctly.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.