diff --git a/web-app/django/VIM/templates/404.html b/web-app/django/VIM/templates/404.html index 6009fa2..e9e964d 100644 --- a/web-app/django/VIM/templates/404.html +++ b/web-app/django/VIM/templates/404.html @@ -1,10 +1,15 @@ {% extends "base.html" %} - -{% block title %} -Oops -{% endblock %} - {% block content %} -

Oops

-

We can't seem to find the page you are looking for.

-{% endblock%} \ No newline at end of file +
+
+
+

404

+
Page not found
+
+

+ We couldn't find a page at this address. +

+
+
+
+{% endblock %} diff --git a/web-app/django/VIM/urls.py b/web-app/django/VIM/urls.py index 1773861..08e6910 100644 --- a/web-app/django/VIM/urls.py +++ b/web-app/django/VIM/urls.py @@ -31,3 +31,12 @@ if settings.IS_DEVELOPMENT: urlpatterns += [path("__debug__/", include("debug_toolbar.urls"))] + + +############################################################### +# Custom error handlers # +# These handlers define custom views to be displayed for # +# specific HTTP error responses. # +############################################################### +# pylint: disable=invalid-name +handler404 = "VIM.views.custom_404_page_not_found" diff --git a/web-app/django/VIM/views.py b/web-app/django/VIM/views.py new file mode 100644 index 0000000..b19f0f6 --- /dev/null +++ b/web-app/django/VIM/views.py @@ -0,0 +1,23 @@ +""" +Module for custom error views. +""" + +from django.http import HttpRequest, HttpResponse +from django.shortcuts import render + + +# pylint: disable=unused-argument +def custom_404_page_not_found( + request: HttpRequest, exception: Exception +) -> HttpResponse: + """ + Custom view to handle 404 errors. + + Args: + request (HttpRequest): The request object. + exception (Exception): The exception that triggered the 404 error. + + Returns: + HttpResponse: Rendered 404 error page. + """ + return render(request, "404.html", status=404)