replace '%r' from string '\nServer stopped.\nNote that the test database, %r, has not been deleted. You can explore it on your own.', with db_name, substitute it for shutdown_message.
shutdown_message = '\nServer stopped.\nNote that the test database, %r, has not been deleted. You can explore it on your own.' % db_name