PythiloLesson 5 of 5 · progress kept in this browser

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),
]
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.

All lessons