Procházet zdrojové kódy

add other error pages

master
erichhasl před 8 roky
rodič
revize
fb7bd9db48
3 změnil soubory, kde provedl 31 přidání a 2 odebrání
  1. +4
    -1
      web_dev/sas_web/sas_web/urls.py
  2. +17
    -1
      web_dev/sas_web/sas_web/views.py
  3. +10
    -0
      web_dev/sas_web/templates/500.html

+ 4
- 1
web_dev/sas_web/sas_web/urls.py Zobrazit soubor

@@ -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
web_dev/sas_web/sas_web/views.py Zobrazit soubor

@@ -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}))

+ 10
- 0
web_dev/sas_web/templates/500.html Zobrazit soubor

@@ -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 %}

Načítá se…
Zrušit
Uložit