          self.connection.close()
  
          source_database_name = self.connection.settings_dict['NAME']
          target_database_name = self.get_test_db_clone_settings(number)['NAME']
          suffix = self._get_database_create_suffix(template=source_database_name)
          creation_sql = "CREATE DATABASE {} {}".format(self._quote_name(target_database_name), suffix)
  
          with self._nodb_connection.cursor() as cursor:
              try:
                  cursor.execute(creation_sql)
              except Exception:
                  if keepdb:
 
</s> remove                 cursor.execute(creation_sql)
            except Exception:
                if keepdb:
                    return
 </s> add                 self._execute_create_test_db(cursor, test_db_params, keepdb)
            except Exception as e: </s> remove                     cursor.execute("DROP DATABASE %s" % self._quote_name(target_database_name))
                    cursor.execute(creation_sql)
 </s> add                     cursor.execute('DROP DATABASE %(dbname)s' % test_db_params)
                    self._execute_create_test_db(cursor, test_db_params, keepdb) </s> remove                         cursor.execute(
                            "DROP DATABASE %s" % qn(test_database_name))
                        cursor.execute(
                            "CREATE DATABASE %s %s" % (qn(test_database_name),
                                                       suffix))
 </s> add                         cursor.execute('DROP DATABASE %(dbname)s' % test_db_params)
                        self._execute_create_test_db(cursor, test_db_params, keepdb)
        test_db_params = {
            'dbname': self._quote_name(target_database_name),
            'suffix': self._get_database_create_suffix(template=source_database_name),
        }
          self.connection.close()
  
          source_database_name = self.connection.settings_dict['NAME']
          target_database_name = self.get_test_db_clone_settings(number)['NAME']
        test_db_params = {
            'dbname': self._quote_name(target_database_name),
            'suffix': self._get_database_create_suffix(template=source_database_name),
        }
        test_db_params = {
            'dbname': self._quote_name(target_database_name),
            'suffix': self._get_database_create_suffix(template=source_database_name),
        }
        test_db_params = {
            'dbname': self._quote_name(target_database_name),
            'suffix': self._get_database_create_suffix(template=source_database_name),
        }
          with self._nodb_connection.cursor() as cursor:
              try:
                  cursor.execute(creation_sql)
              except Exception:
                  if keepdb:
keep keep keep keep replace replace replace keep keep keep keep keep
 Fixed #25406 -- Removed exception hiding in PostgreSQL test database creation during --keepdb.

Thanks Markus Holtermann and Tim Graham for reviews. 
django/db/backends/postgresql/creation.py