{"id":8992,"library":"flake8-django","title":"flake8-django","description":"flake8-django is a plugin for the Flake8 static code analysis tool, specifically designed to detect bad practices and enforce style guidelines within Django projects. Currently at version 1.4, it sees active, though irregular, development with its last major release in July 2023.","status":"active","version":"1.4","language":"python","source_language":"en","source_url":"https://github.com/rocioar/flake8-django","tags":["flake8","django","linter","code quality","python"],"install":[{"cmd":"pip install flake8-django flake8 Django","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"flake8-django is a plugin for Flake8 and requires it to run. It is a peer dependency.","package":"flake8","optional":false},{"reason":"The plugin analyzes Django-specific code and requires Django to be present in the environment for meaningful checks. It is a peer dependency.","package":"Django","optional":false},{"reason":"Requires Python version 3.7.2 or later, but less than 4.0.0.","package":"python","version":">=3.7.2,<4.0.0","optional":false}],"imports":[{"note":"flake8-django is a plugin, not a library meant for direct import and use in Python code. Its checks are integrated when running the `flake8` command.","symbol":"flake8_django","correct":"No direct import needed. flake8 automatically discovers installed plugins."}],"quickstart":{"code":"import os\n\n# Example Django model for demonstration\n# This code would typically be in a models.py file\nfrom django.db import models\n\nclass MyModel(models.Model):\n    # DJ01: Avoid using null=True on string-based fields\n    name = models.CharField(max_length=255, null=True, blank=True) # Will trigger DJ01\n    description = models.TextField(default='Default description')\n\n    class Meta:\n        # DJ08: Model does not define __str__ method (implicit)\n        pass\n\n# To run flake8-django, save the above in a file (e.g., myapp/models.py)\n# Then, from your project root in the terminal:\n# pip install flake8 flake8-django\n# flake8 .\n# If specific rules like DJ10/DJ11 are desired:\n# flake8 --select=E,F,W,C90,DJ,DJ10,DJ11 .\n","lang":"python","description":"Install flake8 and flake8-django. Then, run `flake8 .` from your Django project's root directory. flake8-django's checks (prefixed with 'DJ') will be automatically included in the output. Some rules, like DJ10 and DJ11 (verbose_name checks), are optional and must be explicitly enabled via the `--select` argument or in a `.flake8` configuration file."},"warnings":[{"fix":"Upgrade to Python 3.7.2 or higher, or pin flake8-django to `<1.1.5`.","message":"Version 1.1.5 dropped support for Python versions below 3.7. Projects still on older Python versions must use an earlier flake8-django release.","severity":"breaking","affected_versions":"<1.1.5"},{"fix":"Ensure your `flake8-django` version is compatible with your `flake8` installation. Consult the GitHub release notes or PyPI for specific compatibility ranges.","message":"flake8-django versions require specific flake8 versions for compatibility. v1.1.3 added compatibility for flake8 4.x, and v1.1.5 added compatibility for flake8 5.x. Users might encounter issues if using incompatible versions.","severity":"gotcha","affected_versions":"All versions, depending on flake8 compatibility"},{"fix":"Enable optional rules by adding them to the `--select` argument when running `flake8` (e.g., `flake8 --select=...,DJ10,DJ11 .`) or by configuring them in your `.flake8` or `pyproject.toml` file.","message":"Optional rules (e.g., DJ10 for `verbose_name`, DJ11 for `verbose_name_plural`) are disabled by default and will not be reported unless explicitly selected.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For optional string fields, use `blank=True` and set a `default` value or handle `null` explicitly, as empty strings are usually preferred over `NULL` in databases for string fields. E.g., `name = models.CharField(max_length=255, blank=True, default='')`.","message":"The DJ01 check warns against using `null=True` on string-based model fields like `CharField` and `TextField`, which is a common Django anti-pattern.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.4':33 '2023':47 'activ':36 'analysi':15 'bad':21 'code':14,51 'current':30 'design':18 'detect':20 'develop':39 'django':3,6,28,49 'enforc':24 'flake8':2,5,12,48 'flake8-django':1,4 'guidelin':26 'irregular':38 'juli':46 'last':42 'linter':50 'major':43 'plugin':9 'practic':22 'project':29 'python':53 'qualiti':52 'releas':44 'see':35 'specif':17 'static':13 'style':25 'though':37 'tool':16 'version':32 'within':27","created_at":"2026-04-16T18:47:54.682053+00:00","updated_at":"2026-04-16T18:47:54.682053+00:00","problems":{"verify_error":"no import statement found"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.4","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/rocioar/flake8-django","docs":null,"changelog":null,"pypi":"https://pypi.org/project/flake8-django/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","web-framework","aws"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"skip","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}