--- name: dj-settings description: Organize Django settings.py into clearly sectioned blocks with banner-style headers. Use proactively whenever modifying src/project/settings.py — adding new settings, removing settings, or restructuring sections. allowed-tools: Read, Edit --- # Organize Django Settings When modifying `src/project/settings.py`, enforce this structure. ## Section Format Every logical group of settings gets a banner header: ```python # ============================================================================= # SECTION NAME # ============================================================================= ``` - Banner lines are exactly 77 characters (`# ` + 75 `=` characters) - Section name is UPPERCASE - One blank line before each banner (except at top of file) - No blank lines between the banner and the first setting in that section - No inline comments explaining what standard Django settings do — the section header is enough ## Section Order Settings must appear in this order. Omit sections that have no settings. 1. **Imports and `BASE_DIR`** (no banner — these are preamble) 2. **LOGGING** 3. **SECURITY** — `SECRET_KEY`, `DEBUG`, `ALLOWED_HOSTS`, CORS, CSRF, cookie settings 4. **APPLICATION DEFINITION** — `INSTALLED_APPS`, `MIDDLEWARE` 5. **URLS AND WSGI** — `ROOT_URLCONF`, `WSGI_APPLICATION` 6. **TEMPLATES** 7. **AUTH** — `AUTH_USER_MODEL`, `AUTH_PASSWORD_VALIDATORS`, `LOGIN_URL` 8. **DATABASE** 9. **SESSIONS** 10. **CACHING** 11. **INTERNATIONALIZATION** — `LANGUAGE_CODE`, `TIME_ZONE`, `USE_I18N`, `USE_TZ` 12. **STATIC FILES** — `STATIC_URL`, `STATIC_ROOT`, `DEFAULT_AUTO_FIELD` 13. **CELERY** — all `CELERY_*` settings 14. Any additional project-specific sections in alphabetical order ## `INSTALLED_APPS` Sub-grouping Within `INSTALLED_APPS`, group entries with inline comments: ```python INSTALLED_APPS = [ # Django core "django.contrib.admin", ... # Third-party "corsheaders", ... # Project apps "products.apps.ProductsConfig", "orders.apps.OrdersConfig", ] ``` Project apps must use the dotted path to their `AppConfig` subclass (e.g., `"myapp.apps.MyAppConfig"`), not the short app name. ## Rules - Do NOT add Django docs URLs as comments (e.g., `# https://docs.djangoproject.com/...`) - Do NOT add "Quick-start" or "Generated by" boilerplate comments - Keep `AUTH_PASSWORD_VALIDATORS` compact — one dict per line when the only key is `"NAME"` - When adding a new setting, place it in the correct existing section. Create a new section only if none fit.