Skip to main content

flake8-django

pypi CICodecov Downloads

A flake8 plugin to detect bad practices on Django projects.

Installation

Install from pip with:

$ pip install flake8-django

Testing

flake8-django uses pytest for tests. To run them use:

$ pytest

Run coverage report using:

$ pytest --cov=.

List of Rules

Rule Description
DJ01 Avoid using null=True on string-based fields such as CharField and TextField
DJ03 Avoid passing locals() as context to a render function
DJ06 Do not use exclude with ModelForm, use fields instead
DJ07 Do not use __all__ with ModelForm, use fields instead
DJ08 Model does not define __str__ method
DJ12 Order of Model's inner classes, methods, and fields does not follow the Django Style Guide
DJ13 @receiver decorator must be on top of all the other decorators

More details about each of the Rules can be found on the wiki page.

Optional Rules - Disabled by Default

Rule Description
DJ10 Model should define verbose_name on its Meta inner class
DJ11 Model should define verbose_name_plural on its Meta inner class

To enable optional rules you can use the --select parameter. It's default values are: E,F,W,C90.

For example, if you wanted to enable DJ10, you could call flake8 in the following way:

flake8 --select=E,F,W,C90,DJ,DJ10

You could also add it to your configuration file:

[flake8]
max-line-length = 120
...
select = C,E,F,W,DJ,DJ10

Licence

GPL

Thanks

@stummjr for teaching me AST, and what I could do with it. His blog is cool.

Release files for flake8-django 1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8-django 1.4
File Size Uploaded
flake8_django-1.4.tar.gz 8.4 kB Details

Release files / flake8_django-1.4.tar.gz

Download URL flake8_django-1.4.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4debba883084191568e3187416d1d6bdd4abd826da988f197a3c36572e9f30de
BLAKE2b-256 checksum
How to use checksums
12ae53732f91619ff1130e7c13eb6572e2751dbe4a31c0f30ac4a9e7352c9050
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.4 This release

1 release file

1.3

2 release files

1.2

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

4 release files

1.0.0

2 release files

0.0.4

3 release files

0.0.3

3 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page