Search⌘ K

Dynamic Routing with Path Converters

Explore how to implement dynamic routing in Django using path converters to pass typed parameters like integers or UUIDs to view functions. Understand the use of converters such as int, str, slug, uuid, and path to build flexible URL patterns. This lesson helps you apply type conversion to URL parameters for practical tasks like validating user input or performing computations in views.

In the example from the previous lesson, we used the path <age>, where age was a variable. Then, the value that we appended in the URL at the place of age, that value was passed as a string type parameter to the view function age(). This is the default behavior that the string data type parameters will have. However, we can use a converter to convert this value into another datatype before passing it to the view function. A general use-case for this conversion could be that we want to take the age of the user and apply computations to it to find ...