5.4.2 Adding a URL Pattern for tag_detail

With our tag_detail() function view fully programmed, we now need to point Django to it by adding a URL pattern to the URL configuration. The pattern will be in the form of url(<regular_expression>, tag_detail), where the value of <regular_expression> is currently unknown. In this section, we need to solve two problems:

1. We need to build a regular expression that allows for multiple inputs. For example, /tag/django/ and /tag/web/ must both be valid URL paths.

2. We must pass the value of the slug in the URL path to the detail view.

The answer to both of these problems is to use regular expressions groups.

To solve the first case, we first begin by building a static regular expression. Remember that ...

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.