I would like to know how to show personalized errors with the get_object_or_404 method. I don’t want the normal Http404 pages, but I want to display a custom message with the message: the result is none.
Thanks 🙂
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
get_object_or_404()is essentially a simple 5-line function. Unless you have some specific reason for using it, just do:If for whatever reason you have to use get_object_or_404(), you can try putting it in a
try: ... except Http404: ...block, but I honestly can’t think of a plausible reason for that.