About Using Django Database URL
You can use dj-database-url to read database configuration from environment variable DATABASE_URL
:
import dj_database_url
DATABASES["default"] = dj_database_url.config(
conn_max_age=600, ssl_require=True,
)
Here are examples of DATABASE_URL
definitions for different databases:
# PostgreSQL
export DATABASE_URL="postgres://username:password@localhost:5432/db_name"
# MySQL
export DATABASE_URL="mysql://username:password@localhost:3306/db_name"
# SQLite
export DATABASE_URL="sqlite:///absolute/path/to/db_name.sqlite3"
Tips and Tricks Programming Dev Ops Django 4.2 Django 3.2 Django 2.2
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django GDPR Cookie Consent app
For Django websites that use cookies.