add other error pages
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}))
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
{% extends "public/default.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Tut mir leid, das sollte nicht vorkommen!</h1>
|
||||
|
||||
<p>Es ist ein interner Fehler aufgetreten, bei Fragen wende dich einfach per Kontakt an uns.</p>
|
||||
|
||||
<p><a href="{% url "startpage:index" %}">Hier</a> geht es zurück zur Startseite.</p>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user