How to create ssl connection between django and postgresql
Edit the settings.py
file like this:
Jun 29, 2023
DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# },
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'HOST': 'server-ip',
'PORT': '5432',
'NAME': 'database-name',
'USER': 'username',
'PASSWORD': 'password',
'OPTIONS': {
'sslmode': 'require',
'sslcert': '/path/to/file',
'sslkey': '/path/to/file',
'sslrootcert': '/path/to/file',
},
},
}