# flake8-django
[![pypi](https://img.shields.io/pypi/v/flake8-django.svg)](https://pypi.python.org/pypi/flake8-django/)
![CI](https://github.com/rocioar/flake8-django/workflows/CI/badge.svg)[![Codecov](https://codecov.io/gh/rocioar/flake8-django/branch/master/graph/badge.svg)](https://codecov.io/gh/rocioar/flake8-django)
[![Downloads](https://pepy.tech/badge/flake8-django)](https://pepy.tech/project/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`](https://github.com/rocioar/flake8-django/wiki/%5BDJ01%5D-Avoid-using-null=True-on-string-based-fields-such-as-CharField-and-TextField) | Avoid using null=True on string-based fields such as CharField and TextField |
| [`DJ03`](https://github.com/rocioar/flake8-django/wiki/%5BDJ03%5D-Avoid-passing-locals()-as-context-to-a-render-function) | Avoid passing locals() as context to a render function |
| [`DJ06`](https://github.com/rocioar/flake8-django/wiki/%5BDJ06%5D-Do-not-use-exclude-with-ModelForm,-use-fields-instead) | Do not use exclude with ModelForm, use fields instead |
| [`DJ07`](https://github.com/rocioar/flake8-django/wiki/%5BDJ07%5D-Do-not-set-fields-to-'__all__'-on-ModelForm,-use-fields-instead) | Do not use `__all__` with ModelForm, use fields instead |
| [`DJ08`](https://github.com/rocioar/flake8-django/wiki/%5BDJ08%5D-Model-does-not-define-__str__-method) | Model does not define `__str__` method |
| [`DJ12`](https://github.com/rocioar/flake8-django/wiki/%5BDJ12%5D-Order-of-Model's-inner-classes,-methods,-and-fields-does-not-follow-the-Django-Style-Guide) | Order of Model's inner classes, methods, and fields does not follow the [Django Style Guide](https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#model-style) |
| [`DJ13`](https://github.com/rocioar/flake8-django/wiki/DJ13---@receiver-decorator-must-be-on-top-of-all-the-other-decorators) | @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](https://github.com/rocioar/flake8-django/wiki).
## Optional Rules - Disabled by Default
| Rule | Description |
| ---- | ----------- |
| [`DJ10`](https://github.com/rocioar/flake8-django/wiki/%5BDJ10%5D-Model-should-define-verbose_name-on-its-Meta-inner-class) | Model should define verbose_name on its Meta inner class |
| [`DJ11`](https://github.com/rocioar/flake8-django/wiki/%5BDJ11%5D-Model-should-define-verbose_name_plural-on-its-Meta-inner-class) | 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](https://github.com/stummjr) for teaching me AST, and what I could do with it. His [blog](https://stummjr.org/post/building-a-custom-flake8-plugin/) is cool.
Raw data
{
"_id": null,
"home_page": "https://github.com/rocioar/flake8-django",
"name": "flake8-django",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.2,<4.0.0",
"maintainer_email": "",
"keywords": "flake8,django,lint",
"author": "Rocio Aramberri Schegel",
"author_email": "rocio.aramberri@schegel.net",
"download_url": "https://files.pythonhosted.org/packages/04/7a/8ed46ae0095a3b0e5f3628a95a969ace7c34e30a15c2120be435e0dfbf2a/flake8_django-1.3.tar.gz",
"platform": null,
"description": "# flake8-django\n\n[![pypi](https://img.shields.io/pypi/v/flake8-django.svg)](https://pypi.python.org/pypi/flake8-django/)\n![CI](https://github.com/rocioar/flake8-django/workflows/CI/badge.svg)[![Codecov](https://codecov.io/gh/rocioar/flake8-django/branch/master/graph/badge.svg)](https://codecov.io/gh/rocioar/flake8-django)\n[![Downloads](https://pepy.tech/badge/flake8-django)](https://pepy.tech/project/flake8-django)\n\nA flake8 plugin to detect bad practices on Django projects.\n\n## Installation\n\nInstall from pip with:\n\n```\n$ pip install flake8-django\n```\n\n## Testing\n\nflake8-django uses pytest for tests. To run them use:\n\n```\n$ pytest\n````\n\nRun coverage report using:\n\n```\n$ pytest --cov=.\n```\n\n## List of Rules\n\n| Rule | Description |\n| ---- | ----------- |\n| [`DJ01`](https://github.com/rocioar/flake8-django/wiki/%5BDJ01%5D-Avoid-using-null=True-on-string-based-fields-such-as-CharField-and-TextField) | Avoid using null=True on string-based fields such as CharField and TextField |\n| [`DJ03`](https://github.com/rocioar/flake8-django/wiki/%5BDJ03%5D-Avoid-passing-locals()-as-context-to-a-render-function) | Avoid passing locals() as context to a render function |\n| [`DJ06`](https://github.com/rocioar/flake8-django/wiki/%5BDJ06%5D-Do-not-use-exclude-with-ModelForm,-use-fields-instead) | Do not use exclude with ModelForm, use fields instead |\n| [`DJ07`](https://github.com/rocioar/flake8-django/wiki/%5BDJ07%5D-Do-not-set-fields-to-'__all__'-on-ModelForm,-use-fields-instead) | Do not use `__all__` with ModelForm, use fields instead |\n| [`DJ08`](https://github.com/rocioar/flake8-django/wiki/%5BDJ08%5D-Model-does-not-define-__str__-method) | Model does not define `__str__` method |\n| [`DJ12`](https://github.com/rocioar/flake8-django/wiki/%5BDJ12%5D-Order-of-Model's-inner-classes,-methods,-and-fields-does-not-follow-the-Django-Style-Guide) | Order of Model's inner classes, methods, and fields does not follow the [Django Style Guide](https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#model-style) |\n| [`DJ13`](https://github.com/rocioar/flake8-django/wiki/DJ13---@receiver-decorator-must-be-on-top-of-all-the-other-decorators) | @receiver decorator must be on top of all the other decorators |\n\nMore details about each of the Rules can be found on the [wiki page](https://github.com/rocioar/flake8-django/wiki).\n\n## Optional Rules - Disabled by Default\n\n| Rule | Description |\n| ---- | ----------- |\n| [`DJ10`](https://github.com/rocioar/flake8-django/wiki/%5BDJ10%5D-Model-should-define-verbose_name-on-its-Meta-inner-class) | Model should define verbose_name on its Meta inner class |\n| [`DJ11`](https://github.com/rocioar/flake8-django/wiki/%5BDJ11%5D-Model-should-define-verbose_name_plural-on-its-Meta-inner-class) | Model should define verbose_name_plural on its Meta inner class |\n\nTo enable optional rules you can use the `--select` parameter. It's default values are: E,F,W,C90.\n\nFor example, if you wanted to enable `DJ10`, you could call `flake8` in the following way:\n```\nflake8 --select=E,F,W,C90,DJ,DJ10\n```\n\nYou could also add it to your configuration file:\n```\n[flake8]\nmax-line-length = 120\n...\nselect = C,E,F,W,DJ,DJ10\n```\n\n## Licence\n\nGPL\n\n## Thanks\n\n[@stummjr](https://github.com/stummjr) for teaching me AST, and what I could do with it. His [blog](https://stummjr.org/post/building-a-custom-flake8-plugin/) is cool.\n\n",
"bugtrack_url": null,
"license": "GPL-3.0-or-later",
"summary": "Plugin to catch bad style specific to Django Projects.",
"version": "1.3",
"project_urls": {
"Homepage": "https://github.com/rocioar/flake8-django",
"Repository": "https://github.com/rocioar/flake8-django"
},
"split_keywords": [
"flake8",
"django",
"lint"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "92d66788db2f4af8c82a2d1ca67cbacf3144fcd153a05a8b21f6347720f2202a",
"md5": "2b82fa5417ef68c60f32d4c1918cdff3",
"sha256": "b6017c024308feca83e178b5c6d69695e3007008e268caee9c360b9ae8fe8deb"
},
"downloads": -1,
"filename": "flake8_django-1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2b82fa5417ef68c60f32d4c1918cdff3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.2,<4.0.0",
"size": 11885,
"upload_time": "2023-05-22T09:56:08",
"upload_time_iso_8601": "2023-05-22T09:56:08.423416Z",
"url": "https://files.pythonhosted.org/packages/92/d6/6788db2f4af8c82a2d1ca67cbacf3144fcd153a05a8b21f6347720f2202a/flake8_django-1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "047a8ed46ae0095a3b0e5f3628a95a969ace7c34e30a15c2120be435e0dfbf2a",
"md5": "2f72f3e79ed4ca752793c107bf75dbda",
"sha256": "66fb4227eb9805d1ce5d74d6bf33ba93008aeb4ff1806c0591d1d4a62e38b20e"
},
"downloads": -1,
"filename": "flake8_django-1.3.tar.gz",
"has_sig": false,
"md5_digest": "2f72f3e79ed4ca752793c107bf75dbda",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.2,<4.0.0",
"size": 8357,
"upload_time": "2023-05-22T09:56:11",
"upload_time_iso_8601": "2023-05-22T09:56:11.307224Z",
"url": "https://files.pythonhosted.org/packages/04/7a/8ed46ae0095a3b0e5f3628a95a969ace7c34e30a15c2120be435e0dfbf2a/flake8_django-1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-22 09:56:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "rocioar",
"github_project": "flake8-django",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "flake8-django"
}