QamoosTech
Web & APIsRouting and viewsBeginnerDjangoPython

URL Routing

PronunciationYOO-ar-EL ROW-ting

Definition

URL routing matches the path of an incoming request to the code that should handle it, using a table of patterns (in Django, the URLconf).

Where you hear it

In every web framework's first tutorial, in API design (/circles/12/payments), and when a route returns 404 unexpectedly.

Examples

  • Add a route that sends /circles/<id>/ to the detail view.
  • The first matching pattern wins, so order matters.
  • The request to /orders/15/ is routed to the order detail view.

Common mistake

Putting a broad pattern before a specific one. It catches every request and the specific one is never reached.

Don't confuse with

An endpoint, which is the address plus method clients call. Routing is the mechanism that connects it to code.

Say it at work

  • In a meeting or chatCheck the routing table for the path.
  • In an email or ticketNest the routes under /api/v1/.