Plugin to catch bad style specific to Django Projects.
Project description
flake8-django
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 |
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flake8-django-1.1.2.tar.gz
.
File metadata
- Download URL: flake8-django-1.1.2.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/2.7.16 Darwin/20.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4314abb5bacda450d2eae564a0604447111b1b98188e46bca41682ad2ab59d6 |
|
MD5 | 475d003925294201d690d35eeabb9881 |
|
BLAKE2b-256 | 6e29023f28de5f28f5d643938e9a71784f72bed10f419b8258701666c3b0a96f |
Provenance
File details
Details for the file flake8_django-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: flake8_django-1.1.2-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/2.7.16 Darwin/20.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8bfdbe8352c2c5f3788c2a2f6652dd2604af24af07a5aa112206d63ae228fdc |
|
MD5 | a0f929583eaccd2634c8e1f5151f9596 |
|
BLAKE2b-256 | 1dccc012e04478442265e92ec46caef4851c1548308b5969b44172ade424f27b |