HBNetwork / python-decouple

Strict separation of config from code.
MIT License
2.83k stars 196 forks source link

db_default added #138

Closed sjkrta closed 1 year ago

sjkrta commented 2 years ago

was error here

sjkrta commented 2 years ago

Instead of using:

DATABASES = { 'default': config( 'DATABASE_URL', default='sqlite:///' + BASE_DIR.child('db.sqlite3'), cast=db_url ) }


Now, users can do

DATABASES = db_default(DEBUG, CUSTOM_DB_NAME , DATABASE_URL )


Full Code Looks Like this

from decouple import config, Csv, db_default from dj_database_url import parse as db_url

DEBUG = config('DEBUG', cast=bool) DATABASE_URL = config('DATABASE_URL', cast=db_url) CUSTOM_DB_NAME = BASE_DIR / 'custom_db_name.sqlite3'

DATABASES = db_default(DEBUG, CUSTOM_DB_NAME , DATABASE_URL )