diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index 5084d88..261e3d2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -447,6 +447,24 @@ class DatabaseView(PGChildNodeView):
                     )
                 )
         try:
+            # Fetch template name from oid is specified
+            if 'template' in data:
+                SQL = render_template(
+                    "/".join([self.template_path,'properties.sql']),
+                    did=data['template'], conn=self.conn
+                )
+
+                status, res = self.conn.execute_dict(SQL)
+                if not status:
+                    return internal_server_error(errormsg=status)
+
+                if len(res['rows']) == 0:
+                    return gone(
+                        _("Could not find the database on the server.")
+                    )
+
+                data['template'] = res['rows'][0]['name']
+
             # The below SQL will execute CREATE DDL only
             SQL = render_template(
                 "/".join([self.template_path, 'create.sql']),
@@ -709,6 +727,24 @@ class DatabaseView(PGChildNodeView):
                     data[aclcol], allowedacl['acl']
                     )
 
+        # Fetch template name from oid is specified
+        if 'template' in data:
+            SQL = render_template(
+                "/".join([self.template_path, 'properties.sql']),
+                did=data['template'], conn=self.conn
+            )
+
+            status, res = self.conn.execute_dict(SQL)
+            if not status:
+                return internal_server_error(errormsg=status)
+
+            if len(res['rows']) == 0:
+                return gone(
+                    _("Could not find the database on the server.")
+                )
+
+            data['template'] = res['rows'][0]['name']
+
         SQL = render_template(
             "/".join([self.template_path, 'create.sql']),
             data=data, conn=self.conn
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
index 8441b0c..34b9ed7 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
@@ -240,7 +240,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
           id: 'template', label: '{{ _('Template') }}',
           editable: false, type: 'text', group: 'Definition',
           disabled: function(m) { return !m.isNew(); },
-          control: 'node-list-by-name', node: 'database', cache_level: 'server'
+          control: 'node-list-by-id', node: 'database', cache_level: 'server'
         },{
           id: 'spcname', label: '{{ _('Tablespace') }}',
           editable: false, type: 'text', group: 'Definition',
