18
Add the migration exclusion to your .pre-commit-config.yaml
file
- id: black
exclude: ^.*\b(migrations)\b.*$
9
That’s the solution to the problem: pyproject.toml
[tool.black]
exclude = '''
/(
| migrations
)/
'''
- [Django]-Python 3 list(dictionary.keys()) raises error. What am I doing wrong?
- [Django]-How can I avoid "Using selector: EpollSelector" log message in Django?
- [Django]-Uninstall Django completely
2
Try this (note last line):
[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| migrations
)/
'''
- [Django]-Extend base.html problem
- [Django]-Django Generic Views using decorator login_required
- [Django]-How to get an ImageField URL within a template?
2
Maintaining two different places for exclude
config doesn’t look good if avoidable and will not work well for the CI either (should you want to dry run black in the PR checks).
Adding the following works for the pyproject.toml
and then you can run the same in the pre-commit hook and CI:
[tool.black]
...
exclude = '''
(
/(
...
| .+/migrations
)/
)
'''
- [Django]-How do I match the question mark character in a Django URL?
- [Django]-The QuerySet value for an exact lookup must be limited to one result using slicing. Filter error
- [Django]-How to produce a 303 Http Response in Django?
1
to just extend the default exlusions (without adding the whole list), you can just do:
[tool.black]
extend-exclude = '''
/(
| migrations
)/
'''
- [Django]-How to use pdb.set_trace() in a Django unittest?
- [Django]-Detect mobile, tablet or Desktop on Django
- [Django]-Django Footer and header on each page with {% extends }
Source:stackexchange.com