While building [ComicBinder][cb]'s URLs, I wanted a way to differentiate a volume of a title other than one, and a printing of an issue other than one. So, for example, a URL to the second printing of the second volume of Amazing Spider-Man #1 would look like:
/marvel/amazing-spider-man_2/1_2/
That's easy enough with some URLconf
wrangling. What I'm talking about today is automatically redirecting a request for _1
in any of those places to the same URL without the _1
. While technically correct, I want the lack of underscore + number to mean one, and for there to be only one URL for a resource (someone send me a link to a clever article that talks about this).
django.views.generic.simple.redirect_to
to the rescue. Try something like this: