Dimitris Kougioumtzis Blog About technology

TemplateDoesNotExist middleware

Category Django

Posted on Jan. 8, 2018



TemplateDoesNotExist middleware


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from django.template import TemplateDoesNotExist
from django.views.defaults import page_not_found


class TemplateDoesNotExistMiddleware(object):
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        return self.get_response(request)

    def process_exception(self, request, exception):
        if isinstance(exception, TemplateDoesNotExist):
            return page_not_found(request, exception)

About

My name is Dimitris Kougioumtzis and i work as a Web developer at Rapidbounce Company

Elsewhere