

They are, frankly, quite unintuitive and can be intimidating for beginners. Regular expressions are an incredibly powerful pattern mapping tool. This is the id that is being used to store the book uniquely in the database, as defined in the Book Model. In this case we use '' to capture the book id, which must be a specially formatted string and pass it to the view as a parameter named pk (short for primary key). The syntax is very simple: angle brackets define the part of the URL to be captured, enclosing the name of the variable that the view can use to access the captured data.įor example, , will capture the marked pattern and pass the value to the view as a variable "something". You can optionally precede the variable name with a converter specification that defines the type of data (int, str, slug, uuid, path).

as_view ( ), name = 'book-detail' ), ]įor the book-detail path the URL pattern uses a special syntax to capture the specific id of the book that we want to see.
