How to set key-value within .env file using python-decouple

402 Views Asked by At

I am experimenting with the python-decouple library using below code:


if __name__ == '__main__':
    TEMPLATE_DEBUG = config('TEMPLATE_DEBUG')
    DATABASE_URL = config('DATABASE_URL')
    print(TEMPLATE_DEBUG,'\n',DATABASE_URL)
    DEBUG=config('DEBUG', default=False, cast=bool)
    print('DEBUG-->', DEBUG)

.env file:

TEMPLATE_DEBUG=True
DATABASE_URL=mysql://myuser:mypassword@myhost/mydatabase

Is there a way to set nonexisting key-value pair within the .env file using decouple library?

For example, set TOKEN value within .env and keep updating it throughout the code as and when needed.

0

There are 0 best solutions below