Reusable Django utilities and management commands for Toggle projects.
- Shared management command:
wait_for_resources— Wait for database, Redis, Minio (S3) resources to be available before startup
Using uv:
uv pip install "git+ssh://git@github.com/toggle-corp/toggle-django-utils.git@main"Or add to your pyproject.toml:
[project]
dependencies = [
"toggle-django-utils",
]
[tool.uv.sources]
toggle-django-utils = { git = "ssh://git@github.com/toggle-corp/toggle-django-utils", branch = "main" }-
Add to
INSTALLED_APPSin your Django project'ssettings.py:INSTALLED_APPS = [ # ... your other apps ... "toggle_django_utils", ]
-
(Optional) If your
settings.pyuses custom configs, ensure"toggle_django_utils"remains in the app list.
Access the management command:
python manage.py wait_for_resources --db --redisCommand options:
--dbWait for database--redisWait for Redis server--minioWait for Minio (S3 storage)--timeoutSet max wait time (seconds)
Examples:
python manage.py wait_for_resources --db --redis
python manage.py wait_for_resources --timeout 300 --miniotoggle-django-utils/
├─ src/
│ └─ toggle_django_utils/
│ ├─ __init__.py
│ ├─ apps.py
│ ├─ management/
│ │ └─ commands/
│ │ └─ wait_for_resources.py
│ └─ utils/
│ └─ retry.py
├─ pyproject.toml
├─ README.md
- Clone the repository
- Install as editable with uv:
uv pip install -e . - Run type checking and linting:
uv pip install -e ".[dev]" uv run pyright uv run ruff src/
Apache-2.0