I have a function that looks like this: def getBook(request, bookID): book = Books.objects.get(id=bookID) return render_to_response('book.html', {'book': book})
bookID is a \d. In a url like this www.example.com/books/8 bookID will be 8. And the the page response will be the 8th book in the database. This works fine as long as there is an 8th book in the database. If there isn't a 8th book in the database, it will throw an 500 error like this: DoesNotExist at /books/8 Books matching query does not exist. How do I make it redirect to a 404 instead? I have tried to find an answer for a few days now, "try: ... except DoesNotExist" does not seem to work. -- Magnus --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---