Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

postgres django settings

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'db_name',                      
        'USER': 'db_user',
        'PASSWORD': 'db_user_password',
        'HOST': '',
        'PORT': 'db_port_number',
    }
}
Comment

Add PostgreSQL Settings in Django

# Just after the default DATABASE configuration add this in settings.py

POSTGRES_DB = os.environ.get("POSTGRES_DB")
POSTGRES_PASSWORD = os.environ.get("POSTGRES_PASSWORD")
POSTGRES_USER = os.environ.get("POSTGRES_USER")
POSTGRES_HOST = os.environ.get("POSTGRES_HOST")
POSTGRES_PORT = os.environ.get("POSTGRES_PORT")

POSTGRES_READY = (
    POSTGRES_DB is not None
    and POSTGRES_PASSWORD is not None
    and POSTGRES_USER is not None
    and POSTGRES_HOST is not None
    and POSTGRES_PORT is not None
)

if POSTGRES_READY:
    DATABASES = {
        "default": {
            "ENGINE": "django.db.backends.postgresql",
            "NAME": POSTGRES_DB,
            "USER": POSTGRES_USER,
            "PASSWORD": POSTGRES_PASSWORD,
            "HOST": POSTGRES_HOST,
            "PORT": POSTGRES_PORT,
        }
    }
Comment

PREVIOUS NEXT
Code Example
Python :: python map() 
Python :: How to develop a UDP echo client? 
Python :: gradient descent python 
Python :: max deviation in pandas 
Python :: formate a phonenumber in phonenumber package with phonenumberformat 
Python :: how to get SITE_ID in django....shell 
Python :: terminal commands for install python on cpanel 
Python :: get key from value dictionary py 
Python :: global variables python 
Python :: how to change value of categorical variable in python 
Python :: pthon return value with highest occurences 
Python :: drop 0 in np array 
Python :: how to append number in tuple 
Python :: heroku[web.1]: Process exited with status 3 
Python :: css selenium 
Python :: Get a list of categories of categorical variable (Python Pandas) 
Python :: python sqrt function 
Python :: df split into train, validation, test 
Python :: make_response is not defined django 
Python :: upload file to aws 
Python :: python delete dictionary key 
Python :: r char to numeric dataframe all columns 
Python :: django url with string parameter 
Python :: how to open pygame 
Python :: python convert list to list of strings 
Python :: a int and float. python 
Python :: Delete file in python Using the shutil module 
Python :: Python how to use __lt__ 
Python :: multiprocessing in jupyter notebook 
Python :: how to write a python comment 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =