flake8-django
Plugin to catch bad style specific to Django Projects.
What it is and what it does
flake8-django is a linter plugin that integrates Django-specific style checks into the flake8 framework. It enforces a set of rules designed to catch common Django anti-patterns and style violations—for example, flagging null=True on string fields, discouraging locals() in render contexts, and ensuring models define __str__ methods. The plugin works by analyzing your Django code's abstract syntax tree using astroid, then reporting violations as flake8 errors.
You install it alongside flake8, then run flake8 normally; it automatically applies its Django rules to your codebase. Seven rules are enabled by default (DJ01, DJ03, DJ06, DJ07, DJ08, DJ12, DJ13), and two optional rules (DJ10, DJ11) can be enabled via flake8 configuration. It's intended for teams enforcing Django style consistency across a project.
Use it for:
- Enforce consistent Django model field definitions across a team by catching null=True on CharField/TextField.
- Catch ModelForm misconfigurations (exclude vs. fields, __all__ usage) during code review.
- Ensure all Django models define __str__ methods for better debugging and admin interface display.
- Validate that @receiver decorators are placed correctly at the top of other decorators.
- Enforce Django Style Guide compliance for model inner class and method ordering.
- Integrate Django linting into CI/CD pipelines to catch style violations before merge.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A flake8 plugin that detects Django-specific code style violations and anti-patterns in Django projects, enforcing rules like proper null handling on model fields, correct ModelForm configuration, and model method definitions.
Yes, with conditions. Install if you maintain a Django project and want automated enforcement of Django-specific style rules integrated into flake8. The plugin is stable and has no known vulnerabilities, but maintenance is dormant; verify that its rules remain compatible with your Django version before adopting. The copyleft GPL-3.0-or-later license requires compliance if you redistribute or modify the plugin itself, but using it as a development tool typically poses no constraint.
Install
flake8-django on PyPI
pip
pip install flake8-djangouv
uv add flake8-djangopoetry
poetry add flake8-djangoInstalling flake8-django
Before you install
High install friction due to two runtime dependencies. Maintenance is dormant—last release was 2023-07-31, though the repository remains unarchived with 180 stars.
License in practice
Licensed under GPL-3.0-or-later (copyleft). Any project using this plugin must comply with GPLv3+ terms; proprietary or closed-source projects may face licensing constraints.
Quickstart
pip install flake8-django
Then run flake8 on your Django project:
flake8 --select=E,F,W,C90,DJ your_django_app/
Or enable optional rules like DJ10:
flake8 --select=E,F,W,C90,DJ,DJ10 your_django_app/
Requires flake8 and astroid as runtime dependencies; requires Python >=3.7.2,<4.0.0.
Verify before relying
- Whether dormant maintenance status affects compatibility with recent Django versions.
- Whether all seven core rules (DJ01, DJ03, DJ06, DJ07, DJ08, DJ12, DJ13) and two optional rules (DJ10, DJ11) remain effective for current Django codebases.
Package facts
| License | GPL-3.0-or-later (copyleft) |
| Python support | supports the current Python release (>=3.7.2,<4.0.0) |
| Install friction | high — source build required |
| Runtime dependencies | 2 — astroid, flake8 |
| Maintenance | dormant — 1,110 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 87,636/month — #13,779 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_django-1.4.tar.gz
Keywords: flake8, django, lint
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
flake8_simplifyA flake8 plugin that detects and flags…
permissive · top 15,000 on PyPI
wemake-python-styleguideA flake8 plugin that enforces strict,…
permissive · top 15,000 on PyPI
flake8-htmlA flake8 plugin that converts code style…
permissive · top 15,000 on PyPI
flake8-loggingA Flake8 plugin that detects and flags common…
permissive · top 15,000 on PyPI
flake8-quotesA flake8 plugin that enforces consistent quote…
permissive · top 5,000 on PyPI
flake8-annotationsA Flake8 plugin that enforces PEP 3107-style…
permissive · top 15,000 on PyPI
flake8-blackA flake8 plugin that runs black's code style…
permissive · top 15,000 on PyPI
flake8Flake8 is a command-line tool that combines…
permissive · top 1,000 on PyPI
flake8-logging-formatA flake8 extension that enforces logging best…
permissive · top 15,000 on PyPI
flake8-banditIntegrates bandit security checks into flake8…
permissive · top 15,000 on PyPI