How Django routes URLs
Django is a full framework. A project holds apps, and each app usually has models (database tables as classes), views (functions from request to response), and templates (HTML). Requests pass through middleware, then the URL dispatcher picks a view.
Routes are listed in urls.py:
urlpatterns = [
path("articles/", index),
path("articles/<int:year>/", by_year),
path("u/<str:name>/", profile),
]The rules
- Routes have no leading slash.
- The list is tried in order, and the first match wins.
- A converter captures one part:
<int:x>matches digits and gives anint, and<str:x>matches any text except/. A plain<x>meansstr. - Captured values reach the view as keyword arguments.
- The whole path must match, so a missing trailing slash is a different URL.
- If nothing matches, the result is a 404.
The exercise builds this logic with no Django at all, so you can see that it is ordinary code.
Your task
Write resolve(url, patterns), where patterns is a list of (route, view) tuples using <int:x>, <str:x> or <x>. Return (view, kwargs) for the first full match, with int captures converted. Raise the given NotFound when nothing matches.
The explanation opens here once every check passes.