Dive into Code

Discover code snippets, tutorials, and programming insights

Django

TemplateDoesNotExist middleware

TemplateDoesNotExist middleware

python
 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)
windows

Install flake8 in atom editor for windows

Install flake8 in atom editor for windows

python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
Example of my installation

Installation path of python in my computer is

C:\Python36-32

So in control panel in system settings in advanced settings in path i add the following paths

C:\Python36-32
C:\Python36-32\Scripts

Now i reopen the cmd and i enter python. If it worked the python interpreter line opens.

To install flake8 system-wide run the command

pip install flake8

In atom editor install the package linter-flake8.When package is installed in settings of package in path add the full path of package for example in my configuration i have in path:

C:\Python36-32\Scripts\flake8   without the .exe