-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e641888
commit 480213e
Showing
4 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.http import HttpResponseNotFound | ||
from django.http.response import Http404 | ||
from django.template import loader | ||
|
||
|
||
class Custom404(Http404): | ||
def __init__(self, *args, fallback_pages=None, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.fallback_pages = fallback_pages | ||
|
||
|
||
def page_not_found(request, exception): | ||
context = {"fallback_pages": getattr(exception, "fallback_pages", None)} | ||
template = loader.get_template("404.html") | ||
body = template.render(context, request) | ||
return HttpResponseNotFound(body) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters