{"library":"pylint-django","title":"Pylint Django Plugin","description":"Pylint-Django is a Pylint plugin designed to help Pylint understand the intricacies of the Django web framework. It provides specific checkers for Django models, forms, admin, and other components, catching common Django-related issues that a standard Pylint run would miss. The current version is 2.7.0, and it generally releases new versions to support new major releases of Pylint or Django, typically a few times a year.","language":"python","status":"active","last_verified":"Thu May 14","install":{"commands":["pip install pylint-django pylint django"],"cli":null},"imports":["pylint --load-plugins pylint_django <your_django_app_path>"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport subprocess\nimport tempfile\nimport shutil\n\n# Create a temporary directory to simulate a Django app structure\nwith tempfile.TemporaryDirectory() as temp_dir:\n    app_dir = os.path.join(temp_dir, \"myapp\")\n    os.makedirs(app_dir)\n\n    # Create a dummy models.py that pylint-django can analyze\n    models_code = '''\nfrom django.db import models\n\nclass Author(models.Model):\n    name = models.CharField(max_length=100)\n\nclass Book(models.Model):\n    title = models.CharField(max_length=100)\n    # pylint-django will check ForeignKey attributes, e.g., missing related_name\n    author = models.ForeignKey(Author, on_delete=models.CASCADE)\n\n    class Meta:\n        ordering = ['title']\n\n    def __str__(self):\n        return self.title\n'''\n    models_file_path = os.path.join(app_dir, \"models.py\")\n    with open(models_file_path, \"w\") as f:\n        f.write(models_code)\n\n    print(f\"Created temporary Django app file at: {models_file_path}\")\n\n    # Create a minimal settings.py required for Django's ORM and app loading\n    settings_module_path = os.path.join(temp_dir, \"settings.py\")\n    with open(settings_module_path, \"w\") as f:\n        f.write('''\nINSTALLED_APPS = ['myapp']\nSECRET_KEY = 'insecure-key-for-testing'\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.sqlite3',\n        'NAME': 'db.sqlite3',\n    }\n}\n''')\n    # Set DJANGO_SETTINGS_MODULE environment variable for Pylint's context\n    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'\n\n    print(\"Running Pylint with pylint-django loaded...\")\n    try:\n        # Execute pylint from the temporary directory to correctly pick up settings.py\n        result = subprocess.run(\n            [\n                \"pylint\",\n                \"--load-plugins\",\n                \"pylint_django\",\n                \"--disable=all\", # Disable default Pylint checks for clearer output\n                \"--enable=django-model-checks,django-form-checks,django-admin-checks,django-template-checks,django-other-checks\", # Enable specific pylint-django checkers\n                \"--rcfile=NONE\", # Ignore user's pylintrc for consistent results\n                models_file_path # Target file for linting\n            ],\n            capture_output=True,\n            text=True,\n            check=False, # Do not raise exception for non-zero exit codes (linting errors/warnings)\n            cwd=temp_dir # Run subprocess in the temporary directory\n        )\n        print(\"\\n--- Pylint Output ---\")\n        print(result.stdout)\n        if result.stderr:\n            print(\"\\n--- Pylint Errors (stderr) ---\")\n            print(result.stderr)\n        print(\"--- End Pylint Output ---\")\n    except FileNotFoundError:\n        print(\"Error: 'pylint' command not found. Please ensure Pylint and pylint-django are installed.\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n    finally:\n        # Clean up the environment variable\n        del os.environ['DJANGO_SETTINGS_MODULE']\n","lang":"python","description":"This quickstart demonstrates how to run `pylint` with the `pylint-django` plugin enabled on a mock Django `models.py` file. It sets up a minimal environment to allow Django's ORM to be initialized, ensuring `pylint-django` can perform its checks. The output will include any Django-specific linting issues identified by the plugin.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-14","installed_version":"2.7.0","pypi_latest":"2.7.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":50,"avg_install_s":4.7,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pylint-django","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"75.3M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pylint-django","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pylint-django","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.5,"import_time_s":null,"mem_mb":null,"disk_size":"76M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pylint-django","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pylint-django","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"81.4M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pylint-django","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pylint-django","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.5,"import_time_s":null,"mem_mb":null,"disk_size":"82M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pylint-django","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pylint-django","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"72.6M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pylint-django","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pylint-django","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.5,"import_time_s":null,"mem_mb":null,"disk_size":"73M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pylint-django","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pylint-django","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"72.5M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pylint-django","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pylint-django","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.4,"import_time_s":null,"mem_mb":null,"disk_size":"73M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pylint-django","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pylint-django","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"73.6M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pylint-django","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pylint-django","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.4,"import_time_s":null,"mem_mb":null,"disk_size":"74M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pylint-django","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}