From 494351e2e75999d2983237db613b9e861e36eb01 Mon Sep 17 00:00:00 2001 From: Alfredos-Panagiotis Damkalis Date: Thu, 3 Oct 2019 11:39:30 +0300 Subject: [PATCH] Remove custom views of 404 and 500 errors According to Django 1.11 documentation if there are 404.html and 500.html pages in templates root directory then it loads them in case of 404 or 500 errors without any extra code needed. More details in: https://docs.djangoproject.com/en/1.11/ref/views/#error-views Signed-off-by: Alfredos-Panagiotis Damkalis --- db/base/views.py | 19 +------------------ db/urls.py | 4 ---- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/db/base/views.py b/db/base/views.py index c19908f..f938100 100644 --- a/db/base/views.py +++ b/db/base/views.py @@ -12,8 +12,7 @@ from django.contrib.sites.shortcuts import get_current_site from django.core.cache import cache from django.core.exceptions import ObjectDoesNotExist from django.db import OperationalError -from django.http import HttpResponse, HttpResponseNotFound, \ - HttpResponseServerError, JsonResponse +from django.http import HttpResponse, JsonResponse from django.shortcuts import get_object_or_404, redirect, render from django.template.loader import render_to_string from django.urls import reverse @@ -55,22 +54,6 @@ def home(request): ) -def custom_404(request): - """Custom 404 error handler. - - :returns: 404.html - """ - return HttpResponseNotFound(render(request, '404.html')) - - -def custom_500(request): - """Custom 500 error handler. - - :returns: 500.html - """ - return HttpResponseServerError(render(request, '500.html')) - - def robots(request): """robots.txt handler diff --git a/db/urls.py b/db/urls.py index 88d238d..428c408 100644 --- a/db/urls.py +++ b/db/urls.py @@ -11,10 +11,6 @@ from django.views.static import serve from db.api.urls import API_URLPATTERNS from db.base.urls import BASE_URLPATTERNS -# pylint: disable=C0103 -handler404 = 'db.base.views.custom_404' -handler500 = 'db.base.views.custom_500' - urlpatterns = [ # Base url(r'^', include(BASE_URLPATTERNS)),