Whatever Whenever Tech insights, coding tips, and AI stuff
Home New Post
Profile
Login Register

Select a category for your post

Click tags to select/deselect

Markdown supported: # Heading, **bold**, *italic*, `code`, - list items, etc.
Tip: Paste images directly from clipboard or drag-and-drop to upload!

Python Decouple is a great library that helps you strictly separate the settings parameters from your source code.

Installation
console
pip install python-decouple
Simply create a .env text file in your repository’s root directory in the form:
DEBUG=True
ALLOWED_HOSTS=localhost, 127.0.0.1, 192.168.1.202
DB_NAME=dbname
DB_USER=dbadmin
DB_PASS=password
DB_HOST=localhost
Use the env variables in your settings.py
python
from decouple import config
 
...
DEBUG = config('DEBUG', cast=bool)
 
ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv())
 
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': config('DB_NAME'), 
        'USER': config('DB_USER'),
        'PASSWORD': config('DB_PASS'),
        'HOST': config('DB_HOST'),
    }
}
...
Cancel

Add New Category

Add New Tag

Home Search | RSS Sitemap

© 2026 whatever.asia