Adding flake8 to your Django project

Let's add some flake8 to your Django project.What is flake8? It's a tool that will check all your Python files for correct syntax, pep8 and complexity.

First install flake8 like so:

$ pip install flake8==2.1.0

Now create a file named linters.sh in your project root (next to manage.py):

#!/bin/bash
flake8 --config=./linter.config .

Make sure this file is executable:

$ chmod +x linters.sh

Now create a config file linters.config in your project root:

[flake8]
ignore=E501,E225,E261,W391,E241
exclude=**/yourproject/settings*.py,**/yourproject/__init__.py,**/migrations
max-complexity=10

Where yourproject should be replaced with your projectname.

To execute the linter script:

$ ./linters.sh