O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required