Add user-friendly explanation to 404 error template
This commit is contained in:
+4
-1
@@ -686,7 +686,10 @@ def stats(request):
|
|||||||
|
|
||||||
# HTTP Error 400
|
# HTTP Error 400
|
||||||
def page_not_found(request, exception):
|
def page_not_found(request, exception):
|
||||||
response = render(request, "404.html")
|
# Provide the exception message (reason) to the template so callers
|
||||||
|
# can show a user-friendly explanation when available.
|
||||||
|
context = {"reason": str(exception) if exception is not None else "Not found"}
|
||||||
|
response = render(request, "404.html", context=context)
|
||||||
|
|
||||||
response.status_code = 404
|
response.status_code = 404
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user