django-dev-helpers 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. django_dev_helpers-0.1.0/.github/workflows/ci.yml +63 -0
  2. django_dev_helpers-0.1.0/.gitignore +49 -0
  3. django_dev_helpers-0.1.0/.pre-commit-config.yaml +31 -0
  4. django_dev_helpers-0.1.0/.uv-cache/.gitignore +1 -0
  5. django_dev_helpers-0.1.0/.uv-cache/.lock +0 -0
  6. django_dev_helpers-0.1.0/.uv-cache/CACHEDIR.TAG +1 -0
  7. django_dev_helpers-0.1.0/.uv-cache/interpreter-v4/df9b60572b5055b7/6bc561455c93061c.msgpack +0 -0
  8. django_dev_helpers-0.1.0/.uv-cache/sdists-v9/.git +0 -0
  9. django_dev_helpers-0.1.0/.uv-cache/sdists-v9/.gitignore +0 -0
  10. django_dev_helpers-0.1.0/AGENTS.md +1 -0
  11. django_dev_helpers-0.1.0/CHANGELOG.md +66 -0
  12. django_dev_helpers-0.1.0/CLAUDE.md +31 -0
  13. django_dev_helpers-0.1.0/LICENSE +21 -0
  14. django_dev_helpers-0.1.0/PKG-INFO +194 -0
  15. django_dev_helpers-0.1.0/README.md +159 -0
  16. django_dev_helpers-0.1.0/docs/agent-help.md +79 -0
  17. django_dev_helpers-0.1.0/docs/autologin.md +108 -0
  18. django_dev_helpers-0.1.0/docs/configuration.md +88 -0
  19. django_dev_helpers-0.1.0/docs/design/spec-v0.1.md +1060 -0
  20. django_dev_helpers-0.1.0/docs/dotfiles.md +79 -0
  21. django_dev_helpers-0.1.0/docs/quickstart.md +68 -0
  22. django_dev_helpers-0.1.0/docs/run-site-integration.md +55 -0
  23. django_dev_helpers-0.1.0/docs/security.md +97 -0
  24. django_dev_helpers-0.1.0/docs/standalone-usage.md +87 -0
  25. django_dev_helpers-0.1.0/docs/with-django-run-site.md +92 -0
  26. django_dev_helpers-0.1.0/pyproject.toml +76 -0
  27. django_dev_helpers-0.1.0/src/django_dev_helpers/__init__.py +1 -0
  28. django_dev_helpers-0.1.0/src/django_dev_helpers/apps.py +61 -0
  29. django_dev_helpers-0.1.0/src/django_dev_helpers/browser.py +90 -0
  30. django_dev_helpers-0.1.0/src/django_dev_helpers/conf.py +241 -0
  31. django_dev_helpers-0.1.0/src/django_dev_helpers/dotfiles.py +330 -0
  32. django_dev_helpers-0.1.0/src/django_dev_helpers/gitignore.py +82 -0
  33. django_dev_helpers-0.1.0/src/django_dev_helpers/management/__init__.py +0 -0
  34. django_dev_helpers-0.1.0/src/django_dev_helpers/management/commands/__init__.py +0 -0
  35. django_dev_helpers-0.1.0/src/django_dev_helpers/management/commands/dev_helpers_check_gitignore.py +30 -0
  36. django_dev_helpers-0.1.0/src/django_dev_helpers/management/commands/dev_helpers_doctor.py +458 -0
  37. django_dev_helpers-0.1.0/src/django_dev_helpers/management/commands/dev_helpers_print_help.py +19 -0
  38. django_dev_helpers-0.1.0/src/django_dev_helpers/management/commands/run_site.py +100 -0
  39. django_dev_helpers-0.1.0/src/django_dev_helpers/project_root.py +18 -0
  40. django_dev_helpers-0.1.0/src/django_dev_helpers/prompt.py +127 -0
  41. django_dev_helpers-0.1.0/src/django_dev_helpers/py.typed +0 -0
  42. django_dev_helpers-0.1.0/src/django_dev_helpers/safety.py +81 -0
  43. django_dev_helpers-0.1.0/src/django_dev_helpers/sidecar.py +87 -0
  44. django_dev_helpers-0.1.0/src/django_dev_helpers/tokens.py +18 -0
  45. django_dev_helpers-0.1.0/src/django_dev_helpers/urls.py +14 -0
  46. django_dev_helpers-0.1.0/src/django_dev_helpers/views.py +48 -0
  47. django_dev_helpers-0.1.0/tests/__init__.py +0 -0
  48. django_dev_helpers-0.1.0/tests/conftest.py +44 -0
  49. django_dev_helpers-0.1.0/tests/settings.py +39 -0
  50. django_dev_helpers-0.1.0/tests/test_agent_help.py +96 -0
  51. django_dev_helpers-0.1.0/tests/test_apps_ready.py +159 -0
  52. django_dev_helpers-0.1.0/tests/test_autologin_view.py +160 -0
  53. django_dev_helpers-0.1.0/tests/test_browser_probe.py +122 -0
  54. django_dev_helpers-0.1.0/tests/test_conf_validation.py +123 -0
  55. django_dev_helpers-0.1.0/tests/test_doctor.py +74 -0
  56. django_dev_helpers-0.1.0/tests/test_dotfiles.py +155 -0
  57. django_dev_helpers-0.1.0/tests/test_gitignore_check.py +240 -0
  58. django_dev_helpers-0.1.0/tests/test_kill_switch.py +81 -0
  59. django_dev_helpers-0.1.0/tests/test_run_site_command.py +126 -0
  60. django_dev_helpers-0.1.0/tests/test_settings_lookup.py +90 -0
  61. django_dev_helpers-0.1.0/tests/test_sidecar.py +154 -0
  62. django_dev_helpers-0.1.0/tests/test_standalone_token_generation.py +36 -0
  63. django_dev_helpers-0.1.0/tests/test_subprocess_token.py +75 -0
  64. django_dev_helpers-0.1.0/tests/test_view_methods.py +22 -0
  65. django_dev_helpers-0.1.0/tests/urls.py +5 -0
  66. django_dev_helpers-0.1.0/uv.lock +425 -0
@@ -0,0 +1,63 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.11", "3.12", "3.13"]
16
+ django-version: ["4.2", "5.0", "5.1", "5.2", "6.0"]
17
+ exclude:
18
+ - python-version: "3.11"
19
+ django-version: "6.0"
20
+
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+
24
+ - name: Set up Python ${{ matrix.python-version }}
25
+ uses: actions/setup-python@v5
26
+ with:
27
+ python-version: ${{ matrix.python-version }}
28
+
29
+ - name: Install uv
30
+ uses: astral-sh/setup-uv@v4
31
+
32
+ - name: Install dependencies
33
+ run: |
34
+ uv pip install --system -e ".[dev]"
35
+ uv pip install --system "Django==${{ matrix.django-version }}"
36
+
37
+ - name: Ruff check
38
+ run: ruff check .
39
+
40
+ - name: Ruff format check
41
+ run: ruff format --check .
42
+
43
+ - name: Tests
44
+ run: pytest -xvs
45
+
46
+ typecheck:
47
+ runs-on: ubuntu-latest
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+
51
+ - name: Set up Python 3.13
52
+ uses: actions/setup-python@v5
53
+ with:
54
+ python-version: "3.13"
55
+
56
+ - name: Install uv
57
+ uses: astral-sh/setup-uv@v4
58
+
59
+ - name: Install dependencies
60
+ run: uv pip install --system -e ".[dev]"
61
+
62
+ - name: Mypy
63
+ run: mypy src/django_dev_helpers
@@ -0,0 +1,49 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.so
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ .eggs/
9
+ *.egg
10
+ .ruff_cache/
11
+ .mypy_cache/
12
+ .pytest_cache/
13
+ htmlcov/
14
+ .coverage
15
+ .env
16
+ .env.*
17
+ !.env.example
18
+ !.env.sample
19
+ .venv/
20
+ venv/
21
+ *.whl
22
+
23
+ # Secrets / credentials (never commit these)
24
+ *.pem
25
+ *.key
26
+ *.p12
27
+ *.pfx
28
+ *.keystore
29
+ *.jks
30
+ id_rsa
31
+ id_dsa
32
+ id_ecdsa
33
+ id_ed25519
34
+ credentials.json
35
+ credentials.yml
36
+ credentials.yaml
37
+ service-account*.json
38
+
39
+ # Project-specific dev-helper dotfiles
40
+ .dev_helpers_token
41
+ .dev_helpers_port
42
+ .dev_helpers_pg_*
43
+ .dev_helpers_redis_*
44
+
45
+ # IDE / editor
46
+ .idea/
47
+ .vscode/
48
+ *.swp
49
+ .DS_Store
@@ -0,0 +1,31 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ - id: end-of-file-fixer
7
+ - id: check-yaml
8
+ - id: check-toml
9
+ - id: check-added-large-files
10
+ args: ["--maxkb=500"]
11
+ - id: detect-private-key
12
+ - id: check-merge-conflict
13
+
14
+ - repo: https://github.com/asottile/pyupgrade
15
+ rev: v3.21.2
16
+ hooks:
17
+ - id: pyupgrade
18
+ args: ["--py311-plus"]
19
+
20
+ - repo: https://github.com/adamchainz/django-upgrade
21
+ rev: 1.30.0
22
+ hooks:
23
+ - id: django-upgrade
24
+ args: ["--target-version", "4.2"]
25
+
26
+ - repo: https://github.com/astral-sh/ruff-pre-commit
27
+ rev: v0.14.0
28
+ hooks:
29
+ - id: ruff
30
+ args: ["--fix"]
31
+ - id: ruff-format
@@ -0,0 +1 @@
1
+ *
File without changes
@@ -0,0 +1 @@
1
+ Signature: 8a477f597d28d172789f06886806bc55
File without changes
@@ -0,0 +1 @@
1
+ CLAUDE.md
@@ -0,0 +1,66 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - `lookup.source = "sidecar"` and inclusion of the run-site `.run-site-config`
12
+ TOML file in the `auto` lookup chain. Order is now: callable → env →
13
+ sidecar → settings.
14
+ - `lookup.callable = "module:attr"` — full primary endpoint resolver,
15
+ pluggable per project.
16
+ - `DEV_HELPERS_AUTOLOGIN_USERNAME` env var picked up as the autologin user
17
+ when `autologin.user_lookup_value` is not set explicitly.
18
+ - Config validation in `conf.py` — unknown keys, invalid `gitignore.mode`,
19
+ invalid `lookup.source`, malformed `extra_cookies`, etc. raise
20
+ `ImproperlyConfigured` at app load.
21
+ - `dev_helpers_doctor` now reports `.run-site-config` parse status and
22
+ warns when legacy `.run_site_*` files are present in the project root.
23
+ - `docs/` directory with quickstart, configuration, autologin, dotfiles,
24
+ agent-help, standalone-usage, with-django-run-site, security guides.
25
+ - Tests for the sidecar reader, config validation, view HTTP-method
26
+ restriction, AppConfig.ready orchestration, and a real-subprocess test
27
+ for token autoreload behavior.
28
+
29
+ ### Changed
30
+ - Autologin view now restricted to `GET` (`@require_http_methods(["GET"])`).
31
+ - Agent help prompt `shlex.quote`-s the DB user/password/name so passwords
32
+ containing quotes/spaces survive the shell snippet.
33
+ - SIGTERM cleanup chains to the previously-installed handler instead of
34
+ replacing it; cleanup is idempotent across atexit + SIGTERM paths.
35
+ - Browser auto-open and agent-help auto-print fire at most once per dev
36
+ session — re-runs of `AppConfig.ready()` (via Django's autoreloader)
37
+ are gated by `DEV_HELPERS_BROWSER_OPENED` / `DEV_HELPERS_HELP_PRINTED`
38
+ sentinel env vars.
39
+ - Dotfile atomic writes now set explicit modes (token = `0o600`, others =
40
+ `0o644`) — the temp-file mode no longer leaks 0o600 to non-secret files.
41
+ - Browser self-probe catches a narrow set of expected exceptions and no
42
+ longer logs every failed attempt with a traceback.
43
+ - Browser open is skipped on Linux without `DISPLAY`/`WAYLAND_DISPLAY`.
44
+ - `gitignore` mode warning now goes through `logger.warning` instead of
45
+ `print(stderr)`.
46
+
47
+ ### Fixed
48
+ - `pyproject.toml` `pythonpath` now includes the repo root so `pytest`
49
+ works without a manual `PYTHONPATH=.`.
50
+ - `pyproject.toml` `[dev]` extras now include `ruff` and `mypy` so CI
51
+ steps using them pass after `uv pip install -e ".[dev]"`.
52
+ - `pyproject.toml` adds `[project.urls]` for OSS hygiene.
53
+ - `__init__.py` exposes `__version__`.
54
+
55
+ ## [0.1.0] - 2026-05-07
56
+
57
+ ### Added
58
+ - Autologin endpoint with token-based authentication
59
+ - Dotfile management (token, port, PG, Redis)
60
+ - Agent help / prompt template
61
+ - Gitignore self-check
62
+ - Browser auto-open with self-probe
63
+ - Production safety kill switch
64
+ - `dev_helpers_doctor` management command
65
+ - `dev_helpers_print_help` management command
66
+ - `dev_helpers_check_gitignore` management command
@@ -0,0 +1,31 @@
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+
5
+ This is a Python package using a `src/` layout. Runtime code lives in `src/django_dev_helpers/`, including Django views, URL helpers, safety checks, configuration, dotfile support, browser opening, and management commands under `management/commands/`. Tests live in `tests/` and use the local Django settings module in `tests/settings.py`. Documentation is in `docs/`, with the frozen design spec in `docs/design/`. CI is defined in `.github/workflows/ci.yml`; packaging metadata and tool configuration are in `pyproject.toml`.
6
+
7
+ ## Build, Test, and Development Commands
8
+
9
+ - `uv sync --extra dev`: install the package and development tools into the local environment.
10
+ - `uv run pytest`: run the full pytest suite with `pytest-django`.
11
+ - `uv run pytest tests/test_autologin_view.py`: run a focused test file.
12
+ - `uv run ruff check .`: lint imports, pyupgrade rules, bugbear checks, and project style rules.
13
+ - `uv run ruff format .`: format Python files.
14
+ - `uv run mypy src/django_dev_helpers`: run type checks with Django stubs.
15
+ - `uv build`: build the distributable package with Hatchling.
16
+
17
+ ## Coding Style & Naming Conventions
18
+
19
+ Target Python 3.11 and keep code compatible with Django 4.2 through 5.2. Use 4-space indentation, typed public helpers where practical, and clear snake_case names for modules, functions, fixtures, and settings keys. Management commands should follow Django naming conventions, such as `dev_helpers_doctor.py`. Ruff is the source of truth for formatting and linting; line length is 120 characters.
20
+
21
+ ## Testing Guidelines
22
+
23
+ Tests use `pytest`, `pytest-django`, and Django’s test database. Name tests `test_*.py` and test functions `test_<behavior>`. Prefer focused tests near the behavior being changed, and update fixtures in `tests/conftest.py` only when the setup is broadly useful. Run `uv run pytest` before submitting changes; run `uv run mypy src/django_dev_helpers` when public APIs, settings, or Django integration points change.
24
+
25
+ ## Commit & Pull Request Guidelines
26
+
27
+ Recent commits use short, direct, capitalized subjects without prefixes, for example `Point CI badge and project URLs at iplweb org`. Keep the first line concise and describe the observable change. Pull requests should include a short summary, test results, linked issues when relevant, and docs updates for user-facing behavior. Include screenshots only for rendered documentation or browser-visible behavior.
28
+
29
+ ## Security & Configuration Tips
30
+
31
+ This package provides development-only conveniences, including an autologin endpoint and generated dotfiles. Do not weaken the `DEBUG=False` safeguards, token checks, localhost restrictions, or failure behavior without updating `docs/security.md` and adding regression tests. Never commit generated `.dev_helpers_*` files or local secrets.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 django-dev-helpers contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-dev-helpers
3
+ Version: 0.1.0
4
+ Summary: Dev-time conveniences for Django projects: autologin endpoint, dotfiles for LLM agents, gitignore self-check
5
+ Project-URL: Homepage, https://github.com/iplweb/django-dev-helpers
6
+ Project-URL: Repository, https://github.com/iplweb/django-dev-helpers
7
+ Project-URL: Issues, https://github.com/iplweb/django-dev-helpers/issues
8
+ Project-URL: Changelog, https://github.com/iplweb/django-dev-helpers/blob/main/CHANGELOG.md
9
+ Author: django-dev-helpers contributors
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Framework :: Django
14
+ Classifier: Framework :: Django :: 4.2
15
+ Classifier: Framework :: Django :: 5.0
16
+ Classifier: Framework :: Django :: 5.1
17
+ Classifier: Framework :: Django :: 5.2
18
+ Classifier: Framework :: Django :: 6.0
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: License :: OSI Approved :: MIT License
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Requires-Python: >=3.11
27
+ Requires-Dist: django>=4.2
28
+ Provides-Extra: dev
29
+ Requires-Dist: django-stubs; extra == 'dev'
30
+ Requires-Dist: mypy>=1.10; extra == 'dev'
31
+ Requires-Dist: pytest-django>=4; extra == 'dev'
32
+ Requires-Dist: pytest>=8; extra == 'dev'
33
+ Requires-Dist: ruff>=0.6; extra == 'dev'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # django-dev-helpers
37
+
38
+ [![CI](https://github.com/iplweb/django-dev-helpers/actions/workflows/ci.yml/badge.svg)](https://github.com/iplweb/django-dev-helpers/actions/workflows/ci.yml)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
40
+ [![Python](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org/)
41
+ [![Django](https://img.shields.io/badge/django-4.2%20%7C%205.0%20%7C%205.1%20%7C%205.2%20%7C%206.0-green)](https://www.djangoproject.com/)
42
+
43
+ Dev-time conveniences for Django projects: autologin endpoint, dotfiles for LLM coding agents, agent help prompt, and gitignore self-check.
44
+
45
+ ## Features
46
+
47
+ - **Autologin endpoint** — one URL logs in a user via token, no interactive login needed
48
+ - **Dotfiles** — `.dev_helpers_token`, `.dev_helpers_port`, `.dev_helpers_pg_*`, `.dev_helpers_redis_*` written to project root for easy `cat` by LLM agents
49
+ - **Agent help prompt** — copy-pasteable curl/psql/redis-cli commands printed at startup
50
+ - **Gitignore self-check** — warns if dotfiles are not in `.gitignore`
51
+ - **Browser auto-open** — opens autologin URL in browser after server starts
52
+ - **Production-safe** — default-off, requires explicit `enabled=True`, raises on `DEBUG=False`
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ pip install django-dev-helpers
58
+ # or
59
+ uv add django-dev-helpers --group dev
60
+ ```
61
+
62
+ ## Quick Start
63
+
64
+ 1. Add to `INSTALLED_APPS`:
65
+
66
+ ```python
67
+ INSTALLED_APPS = [
68
+ # ...
69
+ "django_dev_helpers",
70
+ ]
71
+ ```
72
+
73
+ 2. Enable in settings:
74
+
75
+ ```python
76
+ DJANGO_DEV_HELPERS = {"enabled": True}
77
+ ```
78
+
79
+ Or via environment variable:
80
+ ```bash
81
+ DJANGO_DEV_HELPERS_ENABLED=1 python manage.py runserver
82
+ ```
83
+
84
+ 3. Add URL patterns in your `urls.py`:
85
+
86
+ ```python
87
+ from django_dev_helpers.urls import autologin_urlpatterns
88
+
89
+ urlpatterns = [
90
+ *autologin_urlpatterns(),
91
+ # ... your other URLs
92
+ ]
93
+ ```
94
+
95
+ That's it. On startup, the package will:
96
+ - Generate an autologin token
97
+ - Write dotfiles to your project root
98
+ - Check `.gitignore`
99
+ - Print agent help after first request
100
+ - Open browser with autologin URL
101
+
102
+ ## Usage
103
+
104
+ ### Autologin
105
+
106
+ ```bash
107
+ T=$(cat .dev_helpers_token)
108
+ curl -L "http://localhost:8000/__autologin__/?token=$T"
109
+ ```
110
+
111
+ ### Management Commands
112
+
113
+ ```bash
114
+ python manage.py dev_helpers_doctor # Full diagnostic
115
+ python manage.py dev_helpers_print_help # Print agent prompt
116
+ python manage.py dev_helpers_check_gitignore # Check .gitignore entries
117
+ ```
118
+
119
+ ## Documentation
120
+
121
+ - [Quickstart](docs/quickstart.md)
122
+ - [Configuration reference](docs/configuration.md)
123
+ - [Autologin endpoint](docs/autologin.md)
124
+ - [Dotfiles + lookup chain](docs/dotfiles.md)
125
+ - [Agent help / prompt](docs/agent-help.md)
126
+ - [Standalone usage](docs/standalone-usage.md)
127
+ - [Using with django-run-site](docs/with-django-run-site.md)
128
+ - [Security](docs/security.md)
129
+ - [Original design spec (frozen)](docs/design/spec-v0.1.md) — for design rationale
130
+
131
+ ## Configuration
132
+
133
+ All configuration via `settings.DJANGO_DEV_HELPERS` dict. See [configuration docs](docs/configuration.md) for full reference.
134
+
135
+ ```python
136
+ DJANGO_DEV_HELPERS = {
137
+ "enabled": True,
138
+ "autologin": {
139
+ "user_lookup_field": "username",
140
+ "user_lookup_value": "admin",
141
+ "url_path": "__autologin__/",
142
+ "redirect_to": "/",
143
+ },
144
+ "dotfiles": {
145
+ "enabled": True,
146
+ },
147
+ "agent_help": {
148
+ "auto_print": True,
149
+ },
150
+ "browser_open": {
151
+ "enabled": True,
152
+ },
153
+ "gitignore": {
154
+ "mode": "warn", # warn | auto-add | error | off
155
+ },
156
+ }
157
+ ```
158
+
159
+ ## Security
160
+
161
+ This package exposes an autologin backdoor for development. It is **always off by default**:
162
+
163
+ - `enabled` must be explicitly set to `True` (via settings or env var)
164
+ - Raises `ImproperlyConfigured` if `DEBUG=False` and serving HTTP
165
+ - Autologin view verifies token via `hmac.compare_digest` (timing-safe)
166
+ - Only accepts requests from localhost/127.0.0.1 by default
167
+ - Returns 404 (not 403/401) on any failure — endpoint appears non-existent
168
+
169
+ **Never install this package in production.** Add it only to dev dependencies.
170
+
171
+ ## Requirements
172
+
173
+ - Python >= 3.11
174
+ - Django >= 4.2
175
+
176
+ ## Supported versions
177
+
178
+ Combinations exercised on every push by the CI matrix
179
+ (`.github/workflows/ci.yml`):
180
+
181
+ | | Python 3.11 | Python 3.12 | Python 3.13 |
182
+ |-------------|:-----------:|:-----------:|:-----------:|
183
+ | Django 4.2 | ✓ | ✓ | ✓ |
184
+ | Django 5.0 | ✓ | ✓ | ✓ |
185
+ | Django 5.1 | ✓ | ✓ | ✓ |
186
+ | Django 5.2 | ✓ | ✓ | ✓ |
187
+ | Django 6.0 | — | ✓ | ✓ |
188
+
189
+ Django 6.0 requires Python ≥ 3.12, so the `(3.11, 6.0)` cell is excluded
190
+ from CI.
191
+
192
+ ## License
193
+
194
+ MIT
@@ -0,0 +1,159 @@
1
+ # django-dev-helpers
2
+
3
+ [![CI](https://github.com/iplweb/django-dev-helpers/actions/workflows/ci.yml/badge.svg)](https://github.com/iplweb/django-dev-helpers/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
+ [![Python](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org/)
6
+ [![Django](https://img.shields.io/badge/django-4.2%20%7C%205.0%20%7C%205.1%20%7C%205.2%20%7C%206.0-green)](https://www.djangoproject.com/)
7
+
8
+ Dev-time conveniences for Django projects: autologin endpoint, dotfiles for LLM coding agents, agent help prompt, and gitignore self-check.
9
+
10
+ ## Features
11
+
12
+ - **Autologin endpoint** — one URL logs in a user via token, no interactive login needed
13
+ - **Dotfiles** — `.dev_helpers_token`, `.dev_helpers_port`, `.dev_helpers_pg_*`, `.dev_helpers_redis_*` written to project root for easy `cat` by LLM agents
14
+ - **Agent help prompt** — copy-pasteable curl/psql/redis-cli commands printed at startup
15
+ - **Gitignore self-check** — warns if dotfiles are not in `.gitignore`
16
+ - **Browser auto-open** — opens autologin URL in browser after server starts
17
+ - **Production-safe** — default-off, requires explicit `enabled=True`, raises on `DEBUG=False`
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install django-dev-helpers
23
+ # or
24
+ uv add django-dev-helpers --group dev
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ 1. Add to `INSTALLED_APPS`:
30
+
31
+ ```python
32
+ INSTALLED_APPS = [
33
+ # ...
34
+ "django_dev_helpers",
35
+ ]
36
+ ```
37
+
38
+ 2. Enable in settings:
39
+
40
+ ```python
41
+ DJANGO_DEV_HELPERS = {"enabled": True}
42
+ ```
43
+
44
+ Or via environment variable:
45
+ ```bash
46
+ DJANGO_DEV_HELPERS_ENABLED=1 python manage.py runserver
47
+ ```
48
+
49
+ 3. Add URL patterns in your `urls.py`:
50
+
51
+ ```python
52
+ from django_dev_helpers.urls import autologin_urlpatterns
53
+
54
+ urlpatterns = [
55
+ *autologin_urlpatterns(),
56
+ # ... your other URLs
57
+ ]
58
+ ```
59
+
60
+ That's it. On startup, the package will:
61
+ - Generate an autologin token
62
+ - Write dotfiles to your project root
63
+ - Check `.gitignore`
64
+ - Print agent help after first request
65
+ - Open browser with autologin URL
66
+
67
+ ## Usage
68
+
69
+ ### Autologin
70
+
71
+ ```bash
72
+ T=$(cat .dev_helpers_token)
73
+ curl -L "http://localhost:8000/__autologin__/?token=$T"
74
+ ```
75
+
76
+ ### Management Commands
77
+
78
+ ```bash
79
+ python manage.py dev_helpers_doctor # Full diagnostic
80
+ python manage.py dev_helpers_print_help # Print agent prompt
81
+ python manage.py dev_helpers_check_gitignore # Check .gitignore entries
82
+ ```
83
+
84
+ ## Documentation
85
+
86
+ - [Quickstart](docs/quickstart.md)
87
+ - [Configuration reference](docs/configuration.md)
88
+ - [Autologin endpoint](docs/autologin.md)
89
+ - [Dotfiles + lookup chain](docs/dotfiles.md)
90
+ - [Agent help / prompt](docs/agent-help.md)
91
+ - [Standalone usage](docs/standalone-usage.md)
92
+ - [Using with django-run-site](docs/with-django-run-site.md)
93
+ - [Security](docs/security.md)
94
+ - [Original design spec (frozen)](docs/design/spec-v0.1.md) — for design rationale
95
+
96
+ ## Configuration
97
+
98
+ All configuration via `settings.DJANGO_DEV_HELPERS` dict. See [configuration docs](docs/configuration.md) for full reference.
99
+
100
+ ```python
101
+ DJANGO_DEV_HELPERS = {
102
+ "enabled": True,
103
+ "autologin": {
104
+ "user_lookup_field": "username",
105
+ "user_lookup_value": "admin",
106
+ "url_path": "__autologin__/",
107
+ "redirect_to": "/",
108
+ },
109
+ "dotfiles": {
110
+ "enabled": True,
111
+ },
112
+ "agent_help": {
113
+ "auto_print": True,
114
+ },
115
+ "browser_open": {
116
+ "enabled": True,
117
+ },
118
+ "gitignore": {
119
+ "mode": "warn", # warn | auto-add | error | off
120
+ },
121
+ }
122
+ ```
123
+
124
+ ## Security
125
+
126
+ This package exposes an autologin backdoor for development. It is **always off by default**:
127
+
128
+ - `enabled` must be explicitly set to `True` (via settings or env var)
129
+ - Raises `ImproperlyConfigured` if `DEBUG=False` and serving HTTP
130
+ - Autologin view verifies token via `hmac.compare_digest` (timing-safe)
131
+ - Only accepts requests from localhost/127.0.0.1 by default
132
+ - Returns 404 (not 403/401) on any failure — endpoint appears non-existent
133
+
134
+ **Never install this package in production.** Add it only to dev dependencies.
135
+
136
+ ## Requirements
137
+
138
+ - Python >= 3.11
139
+ - Django >= 4.2
140
+
141
+ ## Supported versions
142
+
143
+ Combinations exercised on every push by the CI matrix
144
+ (`.github/workflows/ci.yml`):
145
+
146
+ | | Python 3.11 | Python 3.12 | Python 3.13 |
147
+ |-------------|:-----------:|:-----------:|:-----------:|
148
+ | Django 4.2 | ✓ | ✓ | ✓ |
149
+ | Django 5.0 | ✓ | ✓ | ✓ |
150
+ | Django 5.1 | ✓ | ✓ | ✓ |
151
+ | Django 5.2 | ✓ | ✓ | ✓ |
152
+ | Django 6.0 | — | ✓ | ✓ |
153
+
154
+ Django 6.0 requires Python ≥ 3.12, so the `(3.11, 6.0)` cell is excluded
155
+ from CI.
156
+
157
+ ## License
158
+
159
+ MIT