14.5 Pagination of Tag List Webpage Using the URL Path

Our goal in this section is to paginate the tag list webpage. Instead of using the query part of the URL, we pass the page number to the path part of the URL. This means that, instead of using request.GET to get the information about the query information, we must get it from the URL configuration (just as we get slug information).

Now we are left with a choice. We could create two URL patterns: one to match /tag/ and one to match /tag/2/. Or we could try to use a single URL pattern for both of those URL paths.

As it turns out, we will need to use two URL patterns. We start by trying to use a single regular expression pattern to match both URL path possibilities and discover why we need ...

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.