Settings¶
djangofmt reads its configuration from the [tool.djangofmt] table of the closest pyproject.toml; command-line arguments take precedence over it.
Top-level¶
Options shared by the formatter (djangofmt) and the linter (djangofmt check).
line-length¶
The line length the formatter should fit code into when possible.
Default value: 120
Type: int
Example usage:
indent-width¶
The number of spaces per indentation level.
Default value: 4
Type: int
Example usage:
profile¶
The template language to parse. Defaults to the file extension when unset
(.html is Django, .jinja/.jinja2/.j2 are Jinja).
Default value: "django"
Type: "django" | "jinja"
Example usage:
custom-blocks¶
Names of custom block tags to treat as paired blocks, so their content is indented instead of left untouched.
Default value: []
Type: list[str]
Example usage:
html-void-self-closing¶
Whether void HTML elements are written self-closing (<br />) or not (<br>).
unchanged keeps whatever the source uses.
Default value: "never"
Type: "never" | "always" | "unchanged"
Example usage:
preserve-unquoted-attrs¶
Whether to leave unquoted attribute values (e.g. prop=True) as-is instead of quoting
them. Useful for template syntaxes that assign non-string values through attributes.
Default value: false
Type: bool
Example usage:
exclude¶
File and directory patterns to exclude from discovery, replacing the default excludes.
A pattern without / (e.g. node_modules) excludes any file or directory with that
name at any depth; a pattern with / (e.g. templates/vendor) is a glob anchored at
the project root (the pyproject.toml directory), where * also crosses /.
Default value: [".bzr", ".direnv", ".eggs", ".git", ".git-rewrite", ".hg", ".mypy_cache", ".nox", ".pants.d", ".pytype", ".ruff_cache", ".svn", ".tox", ".venv", "__pypackages__", "_build", "buck-out", "dist", "node_modules", "venv"]
Type: list[str]
Example usage:
extend-exclude¶
File and directory patterns to exclude in addition to the default excludes.
Default value: []
Type: list[str]
Example usage:
include¶
File patterns to format and lint, replacing the default includes.
Globs are anchored at the project root like exclude and matched against a file's
full path, where * also crosses / (so *.html matches at any depth).
Default value: ["*.html", "*.jinja", "*.jinja2", "*.j2"]
Type: list[str]
Example usage:
extend-include¶
File patterns to format and lint in addition to the default includes.
Default value: []
Type: list[str]
Example usage:
respect-gitignore¶
Whether to skip files ignored by .gitignore, .ignore and friends when discovering files.
Default value: true
Type: bool
Example usage:
force-exclude¶
Whether to apply exclude patterns to files passed on the command line too. Useful when
running under pre-commit, which passes every changed file explicitly.
Default value: false
Type: bool
Example usage:
lint¶
Options for the check command.
select¶
Rules and categories to enable, e.g. category:all, category:correctness or a rule name.
category:default is every category except pedantic.
Default value: ["category:default"]
Type: list[RuleSelector]
Example usage:
ignore¶
Rules and categories to disable. A more specific selector always wins, regardless of order.
Default value: []
Type: list[RuleSelector]
Example usage:
preview¶
Whether to enable rules that are still in preview.
Default value: false
Type: bool
Example usage:
target-version¶
The Django version the templates target, as a major.minor string.
When unset, it comes from the minimum supported Django version in [project] dependencies.
Rules that depend on it stay disabled until it is known.
Default value: null
Type: str
Example usage:
fix¶
Whether to apply safe fixes automatically.
Default value: false
Type: bool
Example usage:
unsafe-fixes¶
Whether to include unsafe fixes when applying with fix. Without fix, diagnostics from
unsafe fixes are still reported as fixable.
Default value: false
Type: bool
Example usage:
show-fixes¶
Whether to list per-rule fix counts after applying fixes.
Default value: false
Type: bool
Example usage:
output-format¶
How diagnostics are rendered.
Default value: "full"
Type: "full" | "concise"
Example usage:
per-file-ignores¶
Rules to disable for files matching a glob pattern, relative to the pyproject.toml
directory.
Default value: {}
Type: dict[str, list[RuleSelector]]
Example usage:
lint.unsorted-tailwind-classes¶
Options for the unsorted-tailwind-classes rule.
prefix¶
The Tailwind prefix your utilities are configured with. Without it, prefixed utilities are treated as unknown classes and left unsorted.
Default value: null
Type: str
Example usage: