Skip to main content

Plugin to catch bad style specific to Django Projects.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_django-1.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

flake8_django-1.3-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file flake8_django-1.3.tar.gz.

File metadata

  • Download URL: flake8_django-1.3.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for flake8_django-1.3.tar.gz
Algorithm Hash digest
SHA256 66fb4227eb9805d1ce5d74d6bf33ba93008aeb4ff1806c0591d1d4a62e38b20e
MD5 2f72f3e79ed4ca752793c107bf75dbda
BLAKE2b-256 047a8ed46ae0095a3b0e5f3628a95a969ace7c34e30a15c2120be435e0dfbf2a

See more details on using hashes here.

Provenance

File details

Details for the file flake8_django-1.3-py3-none-any.whl.

File metadata

  • Download URL: flake8_django-1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for flake8_django-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b6017c024308feca83e178b5c6d69695e3007008e268caee9c360b9ae8fe8deb
MD5 2b82fa5417ef68c60f32d4c1918cdff3
BLAKE2b-256 92d66788db2f4af8c82a2d1ca67cbacf3144fcd153a05a8b21f6347720f2202a

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page