Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
commit e7982bb5b0f53203d627e5a3d4955f6e711f3fa3 1 parent 09bd9d3
Adrian Holovaty authored September 19, 2005

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. 8  django/core/db/backends/postgresql.py
8  django/core/db/backends/postgresql.py
@@ -17,10 +17,12 @@ def __init__(self):
17 17
     def cursor(self):
18 18
         from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PASSWORD, DEBUG, TIME_ZONE
19 19
         if self.connection is None:
20  
-            if DATABASE_NAME == '' or DATABASE_USER == '':
  20
+            if DATABASE_NAME == '':
21 21
                 from django.core.exceptions import ImproperlyConfigured
22  
-                raise ImproperlyConfigured, "You need to specify both DATABASE_NAME and DATABASE_USER in your Django settings file."
23  
-            conn_string = "user=%s dbname=%s" % (DATABASE_USER, DATABASE_NAME)
  22
+                raise ImproperlyConfigured, "You need to specify DATABASE_NAME in your Django settings file."
  23
+            conn_string = "dbname=%s" % DATABASE_NAME
  24
+            if DATABASE_USER:
  25
+                conn_string = "user=%s %s" % (DATABASE_USER, conn_string)
24 26
             if DATABASE_PASSWORD:
25 27
                 conn_string += " password=%s" % DATABASE_PASSWORD
26 28
             if DATABASE_HOST:

0 notes on commit e7982bb

Please sign in to comment.
Something went wrong with that request. Please try again.