TemplateDoesNotExist middleware

Django -- Posted on Jan. 8, 2018

TemplateDoesNotExist middleware

              
                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)
                  
   
            

Related Posts