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

6.4.1 Using url to Create Detail Page Links

Let’s pretend for a moment that we don’t know about get_absolute_url() and that we’re going to stick to using the url template tag directly.

All of our detail pages are dynamic pages with at least one regular expression named group. To reverse a URL pattern with such regular expressions, we saw earlier that we could treat the regular expression pattern like a template and pass the value we want to fill in the character set directly to either reverse() or the url template tag.

6.4.1.1 Using url with Tag Detail

The URL pattern organizer_tag_detail currently reads as shown in Example 6.23.

Example 6.23: Project Code

organizer/urls.py in 0a66a80be9

17    url(r'^tag/(?P<slug>[\w\-]+)/$' ...

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