diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py index 3d0d7a0d2a..8123ec7848 100644 --- a/django/db/backends/postgresql/client.py +++ b/django/db/backends/postgresql/client.py @@ -2,13 +2,14 @@ from django.conf import settings import os def runshell(): - args = [''] - args += ["-U%s" % settings.DATABASE_USER] + args = ['psql'] + if settings.DATABASE_USER: + args += ["-U", settings.DATABASE_USER] if settings.DATABASE_PASSWORD: args += ["-W"] if settings.DATABASE_HOST: - args += ["-h %s" % settings.DATABASE_HOST] + args.extend(["-h", settings.DATABASE_HOST]) if settings.DATABASE_PORT: - args += ["-p %s" % settings.DATABASE_PORT] + args.extend(["-p", str(settings.DATABASE_PORT)]) args += [settings.DATABASE_NAME] os.execvp('psql', args)