Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django environment variables

#make .env and .template.env file
#in settings.py
import environ
env = environ.Env(DEBUG=(bool, False))
READ_DOT_ENV_FILE = env.bool('READ_DOT_ENV_FILE', default=False)
if READ_DOT_ENV_FILE:
  environ.Env.read_env()

DEBUG = env('DEBUG')
SECRET_KEY = env('SECRET_KEY')

#in .env file, put DEBUG = True, SECRET_KEY = 'your secret key'
then in terminal, type the following command
export READ_DOT_ENV_FILE=True
 
PREVIOUS NEXT
Tagged: #django #environment #variables
ADD COMMENT
Topic
Name
7+2 =