URL redirection if wrong url
Posted
by xRobot
on Stack Overflow
See other posts from Stack Overflow
or by xRobot
Published on 2010-05-08T23:51:04Z
Indexed on
2010/05/08
23:58 UTC
Read the original article
Hit count: 179
django
|django-urls
I have this method in my book model:
def get_absolute_url(self):
return "/book/%s/%s/%i/%i/" % ( self.book_title, self.book_editor, self.book_pages, self.id)
So the urls of each book are like this:
example.com/book/the-bible/gesu-crist/938/12/
I want that if there is an error in the url, then I get redirected to the real url by using book.id in the end of the url.
For example if I go to:
example.com/book/A-bible/gesu-crist/938/12/
the I will get redirected to:
example.com/book/the-bible/gesu-crist/938/12/
How can I do that ?
© Stack Overflow or respective owner