skillfed

flake8-django

Plugin to catch bad style specific to Django Projects.

flake8-django v1.4 87.6K downloads/30d#13,779 on PyPI180
Copyleft license GPL-3.0-or-later DORMANT released

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-django

uv

uv add flake8-django

poetry

poetry add flake8-django

Installing 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

Framework :: Flake8License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance

Tags

django code style linterflake8 django plugindjango model field validationdjango best practices checkerdjango anti-pattern detectiondjango code qualitydjango linting rules
django-lintingflake8-plugincode-style

More Python Modules packages