Install & Compatibility
Where this runs
tested against v2.8.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 75.5MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.6s · import 0.000s · 76MB
76MB installed
● package 76MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
pylint_django
✓ pylint --load-plugins pylint_django <your_django_app_path>
Pylint-Django is a Pylint plugin loaded via the Pylint CLI `--load-plugins` argument or configuration file (`load-plugins=pylint_django`), not via a direct Python `import` statement in user code.
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.
import os
import subprocess
import tempfile
import shutil
# Create a temporary directory to simulate a Django app structure
with tempfile.TemporaryDirectory() as temp_dir:
app_dir = os.path.join(temp_dir, "myapp")
os.makedirs(app_dir)
# Create a dummy models.py that pylint-django can analyze
models_code = '''
from django.db import models
class Author(models.Model):
name = models.CharField(max_length=100)
class Book(models.Model):
title = models.CharField(max_length=100)
# pylint-django will check ForeignKey attributes, e.g., missing related_name
author = models.ForeignKey(Author, on_delete=models.CASCADE)
class Meta:
ordering = ['title']
def __str__(self):
return self.title
'''
models_file_path = os.path.join(app_dir, "models.py")
with open(models_file_path, "w") as f:
f.write(models_code)
print(f"Created temporary Django app file at: {models_file_path}")
# Create a minimal settings.py required for Django's ORM and app loading
settings_module_path = os.path.join(temp_dir, "settings.py")
with open(settings_module_path, "w") as f:
f.write('''
INSTALLED_APPS = ['myapp']
SECRET_KEY = 'insecure-key-for-testing'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'db.sqlite3',
}
}
''')
# Set DJANGO_SETTINGS_MODULE environment variable for Pylint's context
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
print("Running Pylint with pylint-django loaded...")
try:
# Execute pylint from the temporary directory to correctly pick up settings.py
result = subprocess.run(
[
"pylint",
"--load-plugins",
"pylint_django",
"--disable=all", # Disable default Pylint checks for clearer output
"--enable=django-model-checks,django-form-checks,django-admin-checks,django-template-checks,django-other-checks", # Enable specific pylint-django checkers
"--rcfile=NONE", # Ignore user's pylintrc for consistent results
models_file_path # Target file for linting
],
capture_output=True,
text=True,
check=False, # Do not raise exception for non-zero exit codes (linting errors/warnings)
cwd=temp_dir # Run subprocess in the temporary directory
)
print("\n--- Pylint Output ---")
print(result.stdout)
if result.stderr:
print("\n--- Pylint Errors (stderr) ---")
print(result.stderr)
print("--- End Pylint Output ---")
except FileNotFoundError:
print("Error: 'pylint' command not found. Please ensure Pylint and pylint-django are installed.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
finally:
# Clean up the environment variable
del os.environ['DJANGO_SETTINGS_MODULE']
Upgrade
Version history
2.8.0latest on PyPI · released Jul 11, 2026
Audit
Dependencies
pylint-django-utilsrequiredInternal utility package required by pylint-django.
pylintoptionalPylint is the core linter that this package extends. Must be installed separately.
djangooptionalDjango is the framework this plugin analyzes. Must be installed separately.