Django connection to Postgresql using cert authentication

Viewed 2397

In Django 1.9, what changes do I have to make in settings.py in order to connect to a postgresql database using cert authentication?

2 Answers

Adding this to settings.py worked for me:

import os

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': '<name>',
        'USER': '<user>',
        'PASSWORD': '<password>',
        'HOST': '<host>',
        'PORT': '25060',   
        'OPTIONS': {
            'sslmode': 'verify-full',
            'sslrootcert': os.path.join(BASE_DIR, 'ca-certificate.crt'),
        },
    },
}
Related