From e7982bb5b0f53203d627e5a3d4955f6e711f3fa3 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 19 Sep 2005 01:23:03 +0000 Subject: [PATCH] Fixed #491 -- Non-user connections are now supported for PostgreSQL. Thanks, jafo@tummy.com git-svn-id: http://code.djangoproject.com/svn/django/trunk@647 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/db/backends/postgresql.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/django/core/db/backends/postgresql.py b/django/core/db/backends/postgresql.py index 150bc3f8880..c623a5eed46 100644 --- a/django/core/db/backends/postgresql.py +++ b/django/core/db/backends/postgresql.py @@ -17,10 +17,12 @@ class DatabaseWrapper: def cursor(self): from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PASSWORD, DEBUG, TIME_ZONE if self.connection is None: - if DATABASE_NAME == '' or DATABASE_USER == '': + if DATABASE_NAME == '': from django.core.exceptions import ImproperlyConfigured - raise ImproperlyConfigured, "You need to specify both DATABASE_NAME and DATABASE_USER in your Django settings file." - conn_string = "user=%s dbname=%s" % (DATABASE_USER, DATABASE_NAME) + raise ImproperlyConfigured, "You need to specify DATABASE_NAME in your Django settings file." + conn_string = "dbname=%s" % DATABASE_NAME + if DATABASE_USER: + conn_string = "user=%s %s" % (DATABASE_USER, conn_string) if DATABASE_PASSWORD: conn_string += " password=%s" % DATABASE_PASSWORD if DATABASE_HOST: