Make Django wait until database is ready. Probes for Docker and Kubernetes.
Project description
Django-probes 
Provides a Django management command to check whether the primary database is ready to accept connections.
Run this command in a Kubernetes or OpenShift Init Container to make your Django application wait until the database is available (e.g. to run database migrations).
Why Should I Use This App?
wait_for_database is a single command for all database engines Django supports. It automatically checks the database you have configured in your Django project settings. No need to code a specific wait command for Postgres, MariaDB, Oracle, etc., no need to pull a database engine specific container just for running the database readiness check.
Installation
The easiest way to install django-probes is with pip or uv, e.g.
pip install django-probes
uv add django-probes
Basic Usage
Add django-probes to your Django application:
INSTALLED_APPS = [
...
'django_probes',
]
2. Add an Init Container to your Kubernetes/OpenShift deployment configuration, which calls the wait_for_database management command:
- kind: Deployment
apiVersion: apps/v1
spec:
template:
spec:
initContainers:
- name: wait-for-database
image: my-django-app:latest
envFrom:
- secretRef:
name: django
command: ['python', 'manage.py', 'wait_for_database']
Use with Your Own Command
Alternatively, you can integrate the wait_for_database command in your own management command, and do things like database migration, load initial data, etc. with roughly the same Kubernetes setup as above.
from django.core.management import call_command
# ...
call_command('wait_for_database')
Command Line Options
The management command comes with sane defaults, which you can override if needed:
- –command, -c:
execute Django management command(s) when the database is ready. This option can be used multiple times, e.g. wait_for_database -c 'migrate' -c 'runserver --skip-checks'
- –database:
which database of settings.DATABASES to wait for, default: default
- –stable, -s:
how long to observe whether connection is stable (seconds), default: 5
- –timeout, -t:
how long to wait for the database before timing out (seconds), default: 180
- –wait-when-alive, -a:
delay between checks when database is up (seconds), default: 1
- –wait-when-down, -d:
delay between checks when database is down (seconds), default: 2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_probes-1.8.0.tar.gz.
File metadata
- Download URL: django_probes-1.8.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c94adc3c0aafa8863169969655780fdb70c8a0ecfc76b50962bab0924164148
|
|
| MD5 |
b5319a4c29bc99a95110119b987790bf
|
|
| BLAKE2b-256 |
54db36f342d6e36052f6910e9034eb6558a80ebd1b53e027b70d044818a00f8f
|
File details
Details for the file django_probes-1.8.0-py3-none-any.whl.
File metadata
- Download URL: django_probes-1.8.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa3bcdd9e6ada3468bda88827ac42d1aa6ae2591c92bf3e9d9cf5ed88ce6a35d
|
|
| MD5 |
3b8224536ed67d6cdd8a7cbaac5a52e6
|
|
| BLAKE2b-256 |
fdc2290df9d64fadc473d5c884df5ee85141e51a694aabdcd6ba9f02b8742d2d
|