November 2015
Beginner to intermediate
840 pages
26h 30m
English
Things get trickier with regular expression patterns that contain character sets, such as the organizer_tag_detail URL pattern, which has the regular expression pattern r'^tag/(?P<slug>[\w\-]+)/$'. When matching URL paths, the character set is useful because it allows both /tag/django/ and /tag/web/ to be matched. However, when reversing a URL, the character set becomes an unknown.
In this instance, URL reversal works like a template (or like a Mad Lib). Django expects us to provide the name of the URL pattern as well as any of the values that it needs to fill in the unknowns. To generate /tag/django/ from r'^tag/(?P<slug>[\w\-]+)/$', we must pass organizer_tag_detail and 'django' ...
Read now
Unlock full access