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 - Create Initial Users:
create_initial_users- Create Users with specified roles and permissions, useful to populate the database with default users during development or testing
Using uv:
uv pip install "git+https://github.com/toggle-corp/banjo-utils.git@v0.1.0"Or add to your pyproject.toml:
[project]
dependencies = [
"banjo-utils",
]
[tool.uv.sources]
banjo-utils = { git = "https://github.com/toggle-corp/banjo-utils", tag = "v0.1.0" }-
Add to
INSTALLED_APPSin your Django project'ssettings.py:INSTALLED_APPS = [ # ... your other apps ... "banjo_utils", ]
Access the management command:
python manage.py wait_for_resources --db --redisCommand options:
--db: Wait for database--redis: Wait for Redis server--minio: Wait for Minio (S3 storage)--timeout: Set max wait time (seconds)
Examples:
python manage.py wait_for_resources --db --redis
python manage.py wait_for_resources --timeout 300 --minio
python manage.py create_initial_users --users-json="
[
{
"username": "admin",
"email": "test@example.com",
"password": "admin123",
"is_superuser": true,
"is_staff": true
},
{
"username": "user1",
"email": "user1@gmail.com",
"password": "user123",
"is_superuser": false,
"is_staff": false
}
]'- Clone the repository
- Install as editable with uv:
uv sync --all-groups --all-extras
- Type checking
uv run --all-groups --all-extras pyright
- Running Tests
uv run --all-groups --all-extras pytest
- Run commands for example project
uv run --all-groups --all-extras python example/manage.py runserver uv run --all-groups --all-extras python example/manage.py wait_for_resources --db --redis
Apache-2.0