Django Coding Practices
Application skill for Django official coding style ingest (awesome-guidelines). Generic Python: python-coding-practices. Framework architecture: skills/django-foundation.
Core Principle
Django code reads as one codebase, black-formatted Python, isort import groups, disciplined templates, ordered models, lazy settings in reusable modules, and i18n-ready strings verified by pre-commit.
When to Use / NOT
- Django apps: models, views, forms, templates, tests.
- Contributing to or mirroring django/django conventions in private projects.
- Setting up pre-commit for Django repos.
NOT when:
- Non-Django Python,
python-coding-practices.
- ORM/query design, middleware architecture,
skills/django-foundation.
- Django admin JavaScript, Django JS style doc (separate).
Workflow
- Python/imports, black, isort, tests (
django-style-python-imports.md).
- Templates/views, DTL +
request (django-style-templates-views.md).
- Models/settings, field order, choices, lazy settings (
django-style-models-settings.md).
- Misc/verify, i18n, hygiene, pre-commit (
django-style-misc-verify.md).
Red Flags
- Unformatted or non-black Python in Django app
- f-strings for translatable user messages
- Complex expressions inside f-string braces
- camelCase model fields or methods
- Meta class before model fields
- Multi-dot relative imports
- Deep import when convenience import exists
{% load %} before {% extends %}
{{user}} or {%tag%} spacing violations
- Unnamed
{% endblock %} on its own line
- View first parameter not named
request
- Import-time
settings.FOO in reusable module
- User-visible strings without gettext
- Author name in source file header
- Trailing whitespace in patches
- pre-commit/flake8 failures on changed files
Verification
pre-commit run on changed files (black, isort, flake8)
python manage.py test for touched apps
- Template extends/spacing manual or linter check
- Model structure checklist on changed models
- i18n grep on new user-facing strings
References
awesome-guidelines/references/django-style-learning-note.md
awesome-guidelines/references/django-style-python-imports.md
awesome-guidelines/references/django-style-templates-views.md
awesome-guidelines/references/django-style-models-settings.md
awesome-guidelines/references/django-style-misc-verify.md
Related skills
python-coding-practices, PEP 8/Google baseline
skills/django-foundation, Django framework patterns
frontend-markup-practices, non-DTL HTML/CSS
1---2name: django-coding-practices3description: Use when authoring or reviewing Django code, black/isort imports, DTL spacing, request-first views, model field order, TextChoices, lazy settings, i18n strings, and pre-commit verification.4---56# Django Coding Practices78Application skill for Django official coding style ingest (`awesome-guidelines`). Generic Python: `python-coding-practices`. Framework architecture: `skills/django-foundation`.910## Core Principle1112Django code reads as **one codebase**, black-formatted Python, isort import groups, disciplined templates, ordered models, lazy settings in reusable modules, and i18n-ready strings verified by pre-commit.1314## When to Use / NOT1516- Django apps: models, views, forms, templates, tests.17- Contributing to or mirroring django/django conventions in private projects.18- Setting up pre-commit for Django repos.1920**NOT when:**2122- Non-Django Python, `python-coding-practices`.23- ORM/query design, middleware architecture, `skills/django-foundation`.24- Django admin JavaScript, Django JS style doc (separate).2526## Workflow27281. **Python/imports**, black, isort, tests (`django-style-python-imports.md`).292. **Templates/views**, DTL + `request` (`django-style-templates-views.md`).303. **Models/settings**, field order, choices, lazy settings (`django-style-models-settings.md`).314. **Misc/verify**, i18n, hygiene, pre-commit (`django-style-misc-verify.md`).3233## Red Flags3435- Unformatted or non-black Python in Django app36- f-strings for translatable user messages37- Complex expressions inside f-string braces38- camelCase model fields or methods39- Meta class before model fields40- Multi-dot relative imports41- Deep import when convenience import exists42- `{% load %}` before `{% extends %}`43- `{{user}}` or `{%tag%}` spacing violations44- Unnamed `{% endblock %}` on its own line45- View first parameter not named `request`46- Import-time `settings.FOO` in reusable module47- User-visible strings without gettext48- Author name in source file header49- Trailing whitespace in patches50- pre-commit/flake8 failures on changed files5152## Verification5354- `pre-commit run` on changed files (black, isort, flake8)55- `python manage.py test` for touched apps56- Template extends/spacing manual or linter check57- Model structure checklist on changed models58- i18n grep on new user-facing strings596061## References6263- `awesome-guidelines/references/django-style-learning-note.md`64- `awesome-guidelines/references/django-style-python-imports.md`65- `awesome-guidelines/references/django-style-templates-views.md`66- `awesome-guidelines/references/django-style-models-settings.md`67- `awesome-guidelines/references/django-style-misc-verify.md`6869## Related skills7071- `python-coding-practices`, PEP 8/Google baseline72- `skills/django-foundation`, Django framework patterns73- `frontend-markup-practices`, non-DTL HTML/CSS