diff --git a/web_dev/sas_web/sas_web/urls.py b/web_dev/sas_web/sas_web/urls.py index 3e221bb..ec36f58 100644 --- a/web_dev/sas_web/sas_web/urls.py +++ b/web_dev/sas_web/sas_web/urls.py @@ -18,7 +18,7 @@ from django.contrib import admin from django.conf.urls.static import static from django.conf import settings -from .views import error_404 +from .views import error_400, error_403, error_404, error_500 urlpatterns = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) @@ -33,4 +33,7 @@ urlpatterns += [ url(r'^', include('startpage.urls', namespace='startpage', app_name='startpage')), ] +handler400 = error_400 +handler403 = error_403 handler404 = error_404 +handler500 = error_500 diff --git a/web_dev/sas_web/sas_web/views.py b/web_dev/sas_web/sas_web/views.py index 2d41d33..06b4a49 100644 --- a/web_dev/sas_web/sas_web/views.py +++ b/web_dev/sas_web/sas_web/views.py @@ -1,7 +1,23 @@ from django.template.loader import render_to_string -from django.http import HttpResponseNotFound +from django.http import (HttpResponseServerError, HttpResponseNotFound, + HttpResponseForbidden, HttpResponseBadRequest) def error_404(request): return HttpResponseNotFound(render_to_string('404.html', context={'url': request.path})) + + +def error_500(request): + return HttpResponseServerError(render_to_string('500.html', + context={'url': request.path})) + + +def error_403(request): + return HttpResponseForbidden(render_to_string('500.html', + context={'url': request.path})) + + +def error_400(request): + return HttpResponseBadRequest(render_to_string('500.html', + context={'url': request.path})) diff --git a/web_dev/sas_web/templates/500.html b/web_dev/sas_web/templates/500.html new file mode 100644 index 0000000..349a137 --- /dev/null +++ b/web_dev/sas_web/templates/500.html @@ -0,0 +1,10 @@ +{% extends "public/default.html" %} + +{% block content %} +

Tut mir leid, das sollte nicht vorkommen!

+ +

Es ist ein interner Fehler aufgetreten, bei Fragen wende dich einfach per Kontakt an uns.

+ +

Hier geht es zurück zur Startseite.

+ +{% endblock %}