18.8.1 NewsLink
URL patterns
At the moment, our website uses the primary keys of NewsLink
objects in the URL patterns of related views. This practice is frowned upon, and we want to switch to using the SlugField
of the NewsLink
object, a field we added in Chapter 10: Revisiting Migrations.
The trick to our new URL patterns is that the slug
does not uniquely identify the NewsLink
object. Instead, the combination of startup
and slug
does. Our URL patterns thus need to use two slugs to identify the NewsLink
. That’s somewhat tricky. All of our pages simply use slug
as a variable name in regular expression patterns, and now we have to differentiate between startup_slug
and newslink_slug
in some instances.
As these views will now be associated with ...
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.