Configuration
Configuration lives in the Django workspace's pyproject.toml under tool.django-lsp.
[tool.django-lsp]
include = ["apps/**"]
exclude = ["apps/generated/**"]
workspace_root = "src"
settings_module = "project.settings.production"All options are optional.
include
Limits indexing to Python files matching at least one glob. Without this option, the complete workspace is eligible for indexing subject to the exclusion rules.
include = ["apps/**", "packages/domain/**"]exclude
Adds glob patterns to the built-in exclusions. Virtual environments, dependency directories, caches, build output, Git metadata, and Django migration directories are excluded by default at any workspace depth.
exclude = ["apps/generated/**", "vendor/**"]For an initial production-only CI rollout, exclude common test layouts explicitly:
exclude = ["**/tests/**", "**/tests.py", "**/test_*.py"]These patterns affect both editor diagnostics and django-lsp check, so local and CI results stay
consistent.
Inline diagnostic suppression
Suppress an intentional warning on the line where it is reported by naming its diagnostic code:
for blog in Blog.objects.all():
audit(blog.author.email) # django-lsp: ignore[DJ001]The directive must be a Python comment, not text inside a string. Keep suppressions narrow and use
exclude when an entire generated or test path should not be analyzed.
workspace_root
Changes the Python import root. Relative paths are resolved from the editor workspace; absolute paths are used directly.
For a src layout:
workspace_root = "src"settings_module
Selects the one module from which settings-like assignments such as AUTH_USER_MODEL are read.
This prevents a similarly named constant in an unrelated module from changing model resolution.
settings_module = "project.settings.production"Without this option, only a module whose final component is settings, such as
project.settings, contributes settings.