diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py
index fa0feff..b417e09 100644
a
|
b
|
class BaseDatabaseCreation(object):
|
285 | 285 | # Create the test database and connect to it. We need to autocommit |
286 | 286 | # if the database supports it because PostgreSQL doesn't allow |
287 | 287 | # CREATE/DROP DATABASE statements within transactions. |
| 288 | old_name = self.connection.settings_dict['NAME'] |
| 289 | self.connection.settings_dict['NAME'] = None |
288 | 290 | cursor = self.connection.cursor() |
| 291 | self.connection.settings_dict['NAME'] = old_name |
| 292 | |
289 | 293 | self._prepare_for_test_db_ddl() |
290 | 294 | try: |
291 | 295 | cursor.execute("CREATE DATABASE %s %s" % (qn(test_database_name), suffix)) |
… |
… |
class BaseDatabaseCreation(object):
|
330 | 334 | # ourselves. Connect to the previous database (not the test database) |
331 | 335 | # to do so, because it's not allowed to delete a database while being |
332 | 336 | # connected to it. |
| 337 | old_name = self.connection.settings_dict['NAME'] |
| 338 | self.connection.settings_dict['NAME'] = None |
333 | 339 | cursor = self.connection.cursor() |
| 340 | self.connection.settings_dict['NAME'] = old_name |
| 341 | |
334 | 342 | self._prepare_for_test_db_ddl() |
335 | 343 | time.sleep(1) # To avoid "database is being accessed by other users" errors. |
336 | 344 | cursor.execute("DROP DATABASE %s" % self.connection.ops.quote_name(test_database_name)) |
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index f0a89e5..1dd4a84 100644
a
|
b
|
class DatabaseWrapper(BaseDatabaseWrapper):
|
152 | 152 | if settings_dict['NAME'] == '': |
153 | 153 | from django.core.exceptions import ImproperlyConfigured |
154 | 154 | raise ImproperlyConfigured("You need to specify NAME in your Django settings file.") |
| 155 | |
155 | 156 | conn_params = { |
156 | | 'database': settings_dict['NAME'], |
| 157 | 'database': settings_dict['NAME'] or 'postgres', |
157 | 158 | } |
158 | 159 | conn_params.update(settings_dict['OPTIONS']) |
159 | 160 | if 'autocommit' in conn_params: |