add other error pages

This commit is contained in:
erichhasl
2017-11-19 17:04:02 +01:00
parent 830c0d5ed6
commit fb7bd9db48
3 changed files with 31 additions and 2 deletions
+4 -1
View File
@@ -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
+17 -1
View File
@@ -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}))