From dcb3ad3319cad5c270a1856fd5f355e37cf9d474 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Wed, 23 Dec 2020 23:39:43 +0100 Subject: Fixed #32292 -- Added support for connection by service name to PostgreSQL. --- django/db/backends/postgresql/client.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'django/db/backends/postgresql/client.py') diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py index 7965401163..2339880967 100644 --- a/django/db/backends/postgresql/client.py +++ b/django/db/backends/postgresql/client.py @@ -16,6 +16,7 @@ class DatabaseClient(BaseDatabaseClient): dbname = settings_dict.get('NAME') or 'postgres' user = settings_dict.get('USER') passwd = settings_dict.get('PASSWORD') + service = options.get('service') sslmode = options.get('sslmode') sslrootcert = options.get('sslrootcert') sslcert = options.get('sslcert') @@ -33,6 +34,8 @@ class DatabaseClient(BaseDatabaseClient): env = {} if passwd: env['PGPASSWORD'] = str(passwd) + if service: + env['PGSERVICE'] = str(service) if sslmode: env['PGSSLMODE'] = str(sslmode) if sslrootcert: -- cgit v1.2.1