{% include "django/forms/widgets/input.html" %}
<a class="button" id="id_show_password">Show</a>

<script type="text/javascript">
    var $ = django.jQuery;
    var togglePasswordDisplayButton = $('#id_show_password');
    var passwordField = $('#id_{{widget.name}}');
    togglePasswordDisplayButton.click(function() {
      if(passwordField.attr('type') === 'password') {
        passwordField.attr('type', 'text');
        togglePasswordDisplayButton.text('Hide');
      } else {
        passwordField.attr('type', 'password');
        togglePasswordDisplayButton.text('Show');
      }
    });
</script>

{% include "django/forms/widgets/input.html" %}
<a class="button" id="id_show_password">Show</a>

<a class="button" id="id_copy_password">Copy</a>

<script type="text/javascript">
(function(){
    var $ = django.jQuery;
    var togglePasswordDisplayButton = $('#id_show_password');
    var passwordField = $('#id_{{widget.name}}');
    togglePasswordDisplayButton.click(function() {
      if(passwordField.attr('type') === 'password') {
        passwordField.attr('type', 'text');
        togglePasswordDisplayButton.text('Hide');
      } else {
        passwordField.attr('type', 'password');
        togglePasswordDisplayButton.text('Show');
      }
    });
})();


function copyToClipboard(text) {
  const hiddenDiv = document.createElement('div');
  const style = hiddenDiv.style;
  style.height = '1px';
  style.width = '1px';
  style.overflow = 'hidden';
  style.position = 'fixed';
  style.top = '0px';
  style.left = '0px';

  const textarea = document.createElement('textarea');
  textarea.readOnly = true;
  textarea.value = text;

  hiddenDiv.appendChild(textarea);
  document.body.appendChild(hiddenDiv);

  textarea.select();
  document.execCommand('copy');
  document.body.removeChild(hiddenDiv);
}

(function($){
    var copyPasswordDisplayButton = $('#id_copy_password');
    var passwordField = $('#id_{{widget.name}}');
    copyPasswordDisplayButton.click(function() {
      copyToClipboard(passwordField.val());
    });
})(django.jQuery)
</script>

Implement copy button for password field in admin site for settings model.
Implement copy button for password field in admin site for settings model.
