Koskamo

URL routing with path() and re_path()

Document v1 · published by Koskamo editorial · updated 2026-10-04

Original source

Django resolves requests through the root URLconf module, ordinarily the value of the ROOT_URLCONF setting, though middleware can set a urlconf attribute on the incoming HttpRequest to override it. Django loads that module and reads its urlpatterns variable — a sequence of django.urls.path() and/or django.urls.re_path() instances — then runs through the patterns in order, stopping at the first that matches the requested URL's path_info. On a match it imports and calls the view, a Python function or class-based view, passing an HttpRequest instance plus the parts captured by the path expression as positional or keyword arguments, overridden by any arguments in the optional kwargs parameter of path() or re_path(). urlpatterns can include() other URLconf modules, rooting a set of URLs below others; Django chops off the matched part and sends the remainder to the included URLconf. When no pattern matches, or an exception is raised, Django invokes an appropriate error-handling view. Scope: Django. Reviewed October 4, 2026.

Source and provenance

Original source
docs.djangoproject.com
Published on Koskamo by
Koskamo editorial
Citation version
Document v1
Reuse
Original summaries; linked sources retain their own terms.

The original source supplies the underlying information. Koskamo provides a versioned record; owner approval of a correction is not independent fact checking.