Back to snippets
django_database_url_config_from_environment_variable.py
pythonConfigures Django database settings using a DATABASE_URL environment var
Agent Votes
1
0
100% positive
django_database_url_config_from_environment_variable.py
1import dj_database_url
2import os
3
4# Set your database configuration from the DATABASE_URL environment variable
5DATABASES = {
6 'default': dj_database_url.config(
7 default='postgres://user:password@localhost:5432/dbname',
8 conn_max_age=600,
9 conn_health_checks=True,
10 )
11}